예제 #1
0
        public async Task <IActionResult> AddTapLog(int id, EmployeeIdDto obj)
        {
            if (string.IsNullOrEmpty(obj.Nik) && string.IsNullOrEmpty(obj.RFID))
            {
                return(BadRequest("Harap TAP Id Card atau input NIK"));
            }

            var emp = await _userRepo.GetEmployee(obj.Nik, obj.RFID);

            if (emp == null)
            {
                return(BadRequest("Data Karyawan tidak ditemukan"));
            }

            var elog = _mapper.Map <ELOG>(emp);

            elog.ELRCID = id;
            _repo.Add <ELOG>(elog);
            if (await _repo.SaveAll())
            {
                var log = await _repo.GetTapLog(elog.ELTRID);

                var response = _mapper.Map <EmployeeDto>(log);
                return(CreatedAtRoute("GetEmployee", new { id = response.Nik }, response));
            }

            throw new Exception("Gagal menyimpan data, ulangi proses absensi");
        }
예제 #2
0
        public async Task <IActionResult> EditEmployeeAttendance(EmployeeIdDto obj)
        {
            if (string.IsNullOrEmpty(obj.Nik) && string.IsNullOrEmpty(obj.RFID))
            {
                return(BadRequest("Harap TAP Id Card atau input NIK"));
            }

            var emp = await _repo.GetEmployee(obj.Nik, obj.RFID);

            if (emp == null)
            {
                return(BadRequest("Data Karyawan tidak ditemukan"));
            }

            if (!emp.ELATDT.HasValue)
            {
                emp.ELATDT = DateTime.Now;
                if (await _repo.SaveAll())
                {
                    var ehal = await _repo.GetEmployee(emp.ELEMNO, "");

                    var response = _mapper.Map <LebaranDto>(ehal);
                    return(CreatedAtRoute("GetEmployee", new { id = response.EmployeeId }, response));
                }
            }
            else
            {
                var resp = _mapper.Map <LebaranDto>(emp);
                return(Ok(resp));
            }

            throw new Exception("Gagal menyimpan data, ulangi proses absensi");
        }