Fixed the bug of Attendance Regularization
This commit is contained in:
parent
727e4794da
commit
7ddb1e2f8e
@ -6,11 +6,12 @@ namespace Marco.Pms.Model.ViewModels.Attendance
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int EmployeeId { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public string? EmployeeAvatar { get; set; }
|
||||
public DateTime? CheckInTime { get; set; }
|
||||
public DateTime? CheckOutTime { get; set; }
|
||||
public string? JobRoleName { get; set; }
|
||||
public ATTENDANCE_MARK_TYPE Activity { get; set; }
|
||||
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ namespace MarcoBMS.Services.Controllers
|
||||
}
|
||||
|
||||
var result = new List<EmployeeAttendanceVM>();
|
||||
Attendance attendance = null;
|
||||
Attendance? attendance = null;
|
||||
|
||||
if (dateFrom == null) fromDate = DateTime.UtcNow.Date;
|
||||
if (dateTo == null && dateFrom != null) toDate = fromDate.AddDays(-1);
|
||||
@ -119,7 +119,7 @@ namespace MarcoBMS.Services.Controllers
|
||||
LastName = teamMember.Employee.LastName
|
||||
};
|
||||
|
||||
attendance = lstAttendance.Find(x => x.EmployeeID == teamMember.EmployeeId);
|
||||
attendance = lstAttendance.Find(x => x.EmployeeID == teamMember.EmployeeId) ?? new Attendance();
|
||||
if (attendance != null)
|
||||
{
|
||||
result1.Id = attendance.Id;
|
||||
@ -158,7 +158,7 @@ namespace MarcoBMS.Services.Controllers
|
||||
}
|
||||
|
||||
var result = new List<EmployeeAttendanceVM>();
|
||||
Attendance attendance = null;
|
||||
Attendance? attendance = null;
|
||||
|
||||
if (date == null) forDate = DateTime.UtcNow.Date;
|
||||
|
||||
@ -166,31 +166,42 @@ namespace MarcoBMS.Services.Controllers
|
||||
|
||||
|
||||
List<ProjectAllocation> projectteam = await _projectsHelper.GetTeamByProject(TenantId, projectId, IncludeInActive);
|
||||
var idList = projectteam.Select(p => p.EmployeeId).ToList();
|
||||
//var emp = await _context.Employees.Where(e => idList.Contains(e.Id)).Include(e => e.JobRole).ToListAsync();
|
||||
var jobRole = await _context.JobRoles.ToListAsync();
|
||||
|
||||
foreach (ProjectAllocation teamMember in projectteam)
|
||||
{
|
||||
|
||||
var result1 = new EmployeeAttendanceVM()
|
||||
if (teamMember.Employee.JobRole != null)
|
||||
{
|
||||
EmployeeAvatar = null,
|
||||
EmployeeId = teamMember.EmployeeId,
|
||||
FirstName = teamMember.Employee.FirstName,
|
||||
LastName = teamMember.Employee.LastName
|
||||
};
|
||||
var result1 = new EmployeeAttendanceVM()
|
||||
{
|
||||
EmployeeAvatar = null,
|
||||
EmployeeId = teamMember.EmployeeId,
|
||||
FirstName = teamMember.Employee.FirstName,
|
||||
LastName = teamMember.Employee.LastName,
|
||||
JobRoleName = teamMember.Employee.JobRole.Name,
|
||||
};
|
||||
|
||||
attendance = lstAttendance.Find(x => x.EmployeeID == teamMember.EmployeeId);
|
||||
if (attendance != null)
|
||||
{
|
||||
result1.Id = attendance.Id;
|
||||
result1.CheckInTime = attendance.InTime;
|
||||
result1.CheckOutTime = attendance.OutTime;
|
||||
result1.Activity = attendance.Activity;
|
||||
//var member = emp.Where(e => e.Id == teamMember.EmployeeId);
|
||||
|
||||
|
||||
attendance = lstAttendance.Find(x => x.EmployeeID == teamMember.EmployeeId) ?? new Attendance();
|
||||
if (attendance != null)
|
||||
{
|
||||
result1.Id = attendance.Id;
|
||||
result1.CheckInTime = attendance.InTime;
|
||||
result1.CheckOutTime = attendance.OutTime;
|
||||
result1.Activity = attendance.Activity;
|
||||
}
|
||||
|
||||
result.Add(result1);
|
||||
}
|
||||
|
||||
result.Add(result1);
|
||||
}
|
||||
|
||||
result.Sort(delegate (EmployeeAttendanceVM x, EmployeeAttendanceVM y) {
|
||||
return x.FirstName.CompareTo(y.FirstName);
|
||||
//return x.FirstName.CompareTo(y.FirstName);
|
||||
return string.Compare(x.FirstName, y.FirstName, StringComparison.Ordinal);
|
||||
});
|
||||
|
||||
return Ok(ApiResponse<object>.SuccessResponse(result, System.String.Format("{0} Attendance records fetched successfully", result.Count), 200));
|
||||
@ -215,8 +226,9 @@ namespace MarcoBMS.Services.Controllers
|
||||
using var transaction = await _context.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
Attendance attendance = await _context.Attendes.FirstOrDefaultAsync(a => a.EmployeeID == recordAttendanceDot.EmployeeID &&
|
||||
a.AttendanceDate.Date == recordAttendanceDot.Date.Date && a.TenantId == TenantId); ;
|
||||
Attendance? attendance = await _context.Attendes.FirstOrDefaultAsync(a => a.Id == recordAttendanceDot.Id && a.TenantId == TenantId); ;
|
||||
|
||||
if (recordAttendanceDot.MarkTime == null) return BadRequest(ApiResponse<object>.ErrorResponse("Invalid Mark Time", "Invalid Mark Time",400));
|
||||
|
||||
DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime);
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace Marco.Pms.Services.Controllers
|
||||
_context = context;
|
||||
_userHelper = userHelper;
|
||||
}
|
||||
[HttpPost("create-activity")]
|
||||
[HttpPost("activity")]
|
||||
public async Task<IActionResult> CreateActivity([FromBody] CreateActivityMasterDto createActivity)
|
||||
{
|
||||
var tenantId = _userHelper.GetTenantId();
|
||||
|
@ -13,6 +13,8 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
context.Response.Headers.Remove("X-Powered-By");
|
||||
context.Response.Headers.Remove("Server");
|
||||
await _next(context);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Loading…
x
Reference in New Issue
Block a user