Passing role name in record attendance api
This commit is contained in:
parent
56448cb8a2
commit
e41faf4045
@ -278,7 +278,7 @@ namespace MarcoBMS.Services.Controllers
|
||||
|
||||
DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime);
|
||||
|
||||
|
||||
//if(recordAttendanceDot.Comment != null)
|
||||
if (attendance != null)
|
||||
{
|
||||
attendance.Comment = recordAttendanceDot.Comment;
|
||||
@ -372,6 +372,8 @@ namespace MarcoBMS.Services.Controllers
|
||||
await transaction.CommitAsync(); // Commit transaction
|
||||
|
||||
Employee employee = await _employeeHelper.GetEmployeeByID(recordAttendanceDot.EmployeeID);
|
||||
if(employee.JobRole != null)
|
||||
{
|
||||
EmployeeAttendanceVM vm = new EmployeeAttendanceVM()
|
||||
{
|
||||
CheckInTime = attendance.InTime,
|
||||
@ -381,10 +383,13 @@ namespace MarcoBMS.Services.Controllers
|
||||
FirstName = employee.FirstName,
|
||||
LastName = employee.LastName,
|
||||
Id = attendance.Id,
|
||||
Activity = attendance.Activity
|
||||
Activity = attendance.Activity,
|
||||
JobRoleName = employee.JobRole.Name
|
||||
};
|
||||
|
||||
return Ok(ApiResponse<object>.SuccessResponse(vm, "Attendance marked successfully.", 200));
|
||||
}
|
||||
return Ok(ApiResponse<object>.SuccessResponse(new EmployeeAttendanceVM(), "Attendance marked successfully.", 200));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -18,7 +18,8 @@ namespace MarcoBMS.Services.Helpers
|
||||
}
|
||||
public async Task<Employee> GetEmployeeByID(int EmployeeID)
|
||||
{
|
||||
return await _context.Employees.FindAsync(EmployeeID);
|
||||
|
||||
return await _context.Employees.Include(e => e.JobRole).FirstOrDefaultAsync(e => e.Id == EmployeeID) ?? new Employee { };
|
||||
}
|
||||
|
||||
public async Task<Employee> GetEmployeeByApplicationUserID(string ApplicationUserID)
|
||||
|
Loading…
x
Reference in New Issue
Block a user