using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FaceTransfer
{
    public class AttendanceDAO
    {
        public AttendanceDAO()
        {
        }
        public void Add(Attendance attendance, MySqlConnection connection)
        {
            string query = "REPLACE INTO `hrms`.`attendance_log` (`ac_no`, `checktime`, `processed`, `machine_id`, `in_out_type_id`, `machine_ip`, `date`) VALUES (@AcNo, @CHECKTIME, @isProcessed, @MachineId, @InOutTypeId, @MachineIP, @Getdate)";

            MySqlCommand cmd = new MySqlCommand(query, connection);
            cmd.Parameters.AddWithValue("@AcNo", attendance.AcNo);
            cmd.Parameters.AddWithValue("@CHECKTIME", attendance.CheckTime);
            cmd.Parameters.AddWithValue("@isProcessed", attendance.IsProcessed);
            cmd.Parameters.AddWithValue("@machineId", attendance.MachineId);
            cmd.Parameters.AddWithValue("@InOutTypeId", attendance.InOutTypeId);
            cmd.Parameters.AddWithValue("@MachineIP", attendance.MachineIp);
            cmd.Parameters.AddWithValue("@Getdate", attendance.Date);

            cmd.ExecuteNonQuery();

        }
    }
}
