When requesting regularization, ensure that the check-out time is later than the check-in time.
This commit is contained in:
parent
e369ccffbb
commit
0bfac5ca4f
@ -336,8 +336,16 @@ namespace MarcoBMS.Services.Controllers
|
||||
{
|
||||
DateTime date = attendance.AttendanceDate;
|
||||
finalDateTime = GetDateFromTimeStamp(date.Date, recordAttendanceDot.MarkTime);
|
||||
if (attendance.InTime < finalDateTime)
|
||||
{
|
||||
attendance.OutTime = finalDateTime;
|
||||
attendance.Activity = ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogError("Employee {EmployeeId} sent regularization request but it check-out time is earlier than check-out");
|
||||
return BadRequest(ApiResponse<object>.ErrorResponse("Check-out time must be later than check-in time", "Check-out time must be later than check-in time", 400));
|
||||
}
|
||||
// do nothing
|
||||
}
|
||||
else if (recordAttendanceDot.Action == ATTENDANCE_MARK_TYPE.REGULARIZE)
|
||||
@ -433,7 +441,13 @@ namespace MarcoBMS.Services.Controllers
|
||||
{
|
||||
await transaction.RollbackAsync(); // Rollback on failure
|
||||
_logger.LogError("{Error} while marking attendance", ex.Message);
|
||||
return BadRequest(ApiResponse<object>.ErrorResponse(ex.Message, ex, 400));
|
||||
var response = new
|
||||
{
|
||||
message = ex.Message,
|
||||
detail = ex.StackTrace,
|
||||
statusCode = StatusCodes.Status500InternalServerError
|
||||
};
|
||||
return BadRequest(ApiResponse<object>.ErrorResponse(ex.Message, response, 400));
|
||||
}
|
||||
|
||||
}
|
||||
@ -495,8 +509,16 @@ namespace MarcoBMS.Services.Controllers
|
||||
{
|
||||
DateTime date = attendance.AttendanceDate;
|
||||
finalDateTime = GetDateFromTimeStamp(date.Date, recordAttendanceDot.MarkTime);
|
||||
if (attendance.InTime < finalDateTime)
|
||||
{
|
||||
attendance.OutTime = finalDateTime;
|
||||
attendance.Activity = ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogError("Employee {EmployeeId} sent regularization request but it check-out time is earlier than check-out");
|
||||
return BadRequest(ApiResponse<object>.ErrorResponse("Check-out time must be later than check-in time", "Check-out time must be later than check-in time", 400));
|
||||
}
|
||||
// do nothing
|
||||
}
|
||||
else if (recordAttendanceDot.Action == ATTENDANCE_MARK_TYPE.REGULARIZE)
|
||||
@ -668,7 +690,13 @@ namespace MarcoBMS.Services.Controllers
|
||||
{
|
||||
await transaction.RollbackAsync(); // Rollback on failure
|
||||
_logger.LogError("{Error} while marking attendance", ex.Message);
|
||||
return BadRequest(ApiResponse<object>.ErrorResponse(ex.Message, ex, 400));
|
||||
var response = new
|
||||
{
|
||||
message = ex.Message,
|
||||
detail = ex.StackTrace,
|
||||
statusCode = StatusCodes.Status500InternalServerError
|
||||
};
|
||||
return BadRequest(ApiResponse<object>.ErrorResponse(ex.Message, response, 400));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user