Showing the list of all attendance even if user have selfattendance permissons

This commit is contained in:
ashutosh.nehete 2025-10-08 14:16:24 +05:30
parent d180d5d60e
commit c47b0da7b8

View File

@ -856,10 +856,10 @@ namespace MarcoBMS.Services.Controllers
lstAttendanceQuery = lstAttendanceQuery.Where(a => a.ProjectID == projectId);
}
Attendance lstAttendance = await lstAttendanceQuery.FirstOrDefaultAsync() ?? new Attendance();
var project = await _context.Projects.FirstOrDefaultAsync(p => p.Id == lstAttendance.ProjectID && p.TenantId == tenantId);
List<Attendance> lstAttendances = await lstAttendanceQuery.ToListAsync() ?? new List<Attendance>();
var projectIds = lstAttendances.Select(a => a.ProjectID).ToList();
var projects = await _context.Projects.Where(p => projectIds.Contains(p.Id) && p.TenantId == tenantId).ToListAsync();
var employee = await _context.Employees
.Include(e => e.Organization)
@ -867,6 +867,8 @@ namespace MarcoBMS.Services.Controllers
.FirstOrDefaultAsync(e => e.Id == employeeId && e.IsActive);
if (employee != null && employee.JobRole != null && employee.Organization != null)
{
foreach (var lstAttendance in lstAttendances)
{
EmployeeAttendanceVM result1 = new EmployeeAttendanceVM
{
@ -875,7 +877,7 @@ namespace MarcoBMS.Services.Controllers
EmployeeId = employee.Id,
FirstName = employee.FirstName,
OrganizationName = employee.Organization.Name,
ProjectName = project?.Name,
ProjectName = projects.Where(p => p.Id == lstAttendance.ProjectID).Select(p => p.Name).FirstOrDefault(),
LastName = employee.LastName,
JobRoleName = employee.JobRole.Name,
CheckInTime = lstAttendance.InTime,
@ -884,6 +886,7 @@ namespace MarcoBMS.Services.Controllers
};
result.Add(result1);
}
}
return result;
}