|
@@ -25,14 +25,34 @@ namespace MTWorkHR.Application.Services
|
|
|
_unitOfWork = unitOfWork;
|
|
|
}
|
|
|
|
|
|
- public override async Task<AttendanceDto> GetById(long id)
|
|
|
+
|
|
|
+ public override async Task<AttendanceDto> Create(AttendanceDto input)
|
|
|
{
|
|
|
- var entity = await _unitOfWork.Attendance.GetByIdWithAllChildren(id);
|
|
|
- var response = MapperObject.Mapper.Map<AttendanceDto>(entity);
|
|
|
+ var entitiy = MapperObject.Mapper.Map<Attendance>(input);
|
|
|
+ if (entitiy is null)
|
|
|
+ throw new AppException(ExceptionEnum.MapperIssue);
|
|
|
+
|
|
|
+ var newEntity = await _unitOfWork.Attendance.AddAsync(entitiy);
|
|
|
+ var Success = await _unitOfWork.CompleteAsync();
|
|
|
+
|
|
|
+ var response = Mapper.MapperObject.Mapper.Map<AttendanceDto>(newEntity);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
+ public override async Task<AttendanceDto> Update(AttendanceDto input)
|
|
|
+ {
|
|
|
+ var entity = await _unitOfWork.Attendance.GetAttendanceByUserId(input.UserId, input.AttendanceDate);
|
|
|
+ if (entity is null)
|
|
|
+ throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
+ entity.CheckOutTime = input.CheckOutTime;
|
|
|
+ entity.LeaveType = input.LeaveType;
|
|
|
+ entity.LeaveReason = input.LeaveReason;
|
|
|
+
|
|
|
+ await _unitOfWork.CompleteAsync();
|
|
|
|
|
|
+ var response = Mapper.MapperObject.Mapper.Map<AttendanceDto>(entity);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|