Created new Api fro getting Attendance of emplyee who requested regularization
This commit is contained in:
parent
7ddb1e2f8e
commit
56448cb8a2
@ -1,10 +1,9 @@
|
||||
using Marco.Pms.Model.Dtos.Attendance;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Marco.Pms.Model.Dtos.Attendance;
|
||||
using Marco.Pms.Model.Employees;
|
||||
using Marco.Pms.Model.Entitlements;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Marco.Pms.Model.AttendanceModule
|
||||
{
|
||||
@ -27,14 +26,14 @@ namespace Marco.Pms.Model.AttendanceModule
|
||||
public int? ApprovedBy { get; set; }
|
||||
[ForeignKey("EmployeeID")]
|
||||
[ValidateNever]
|
||||
public Employee Approver { get; set; }
|
||||
public Employee? Approver { get; set; }
|
||||
|
||||
|
||||
[DisplayName("TenantId")]
|
||||
public int TenantId { get; set; }
|
||||
[ValidateNever]
|
||||
[ForeignKey(nameof(TenantId))]
|
||||
public Tenant Tenant { get; set; }
|
||||
public Tenant? Tenant { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using MarcoBMS.Services.Helpers;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace MarcoBMS.Services.Controllers
|
||||
{
|
||||
@ -207,6 +208,51 @@ namespace MarcoBMS.Services.Controllers
|
||||
return Ok(ApiResponse<object>.SuccessResponse(result, System.String.Format("{0} Attendance records fetched successfully", result.Count), 200));
|
||||
}
|
||||
|
||||
[HttpGet("regularize")]
|
||||
|
||||
public async Task<IActionResult> GetRequestRegularizeAttendance([FromQuery] int projectId, [FromQuery] bool IncludeInActive)
|
||||
{
|
||||
int TenantId = GetTenantId();
|
||||
var result = new List<EmployeeAttendanceVM>();
|
||||
|
||||
List<Attendance> lstAttendance = await _context.Attendes.Where(c => c.ProjectID == projectId && c.Activity == ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE && c.TenantId == TenantId).ToListAsync();
|
||||
|
||||
|
||||
List<ProjectAllocation> projectteam = await _projectsHelper.GetTeamByProject(TenantId, projectId, IncludeInActive);
|
||||
var idList = projectteam.Select(p => p.EmployeeId).ToList();
|
||||
var jobRole = await _context.JobRoles.ToListAsync();
|
||||
|
||||
foreach (Attendance attende in lstAttendance)
|
||||
{
|
||||
var result1 = new EmployeeAttendanceVM()
|
||||
{
|
||||
Id = attende.Id,
|
||||
CheckInTime = attende.InTime,
|
||||
CheckOutTime = attende.OutTime,
|
||||
Activity = attende.Activity,
|
||||
EmployeeAvatar = null,
|
||||
EmployeeId = attende.EmployeeID,
|
||||
|
||||
};
|
||||
|
||||
var teamMember = projectteam.Find(m => m.EmployeeId == attende.EmployeeID);
|
||||
if (teamMember != null && teamMember.Employee.JobRole != null)
|
||||
{
|
||||
result1.FirstName = teamMember.Employee.FirstName;
|
||||
result1.LastName = teamMember.Employee.LastName;
|
||||
result1.JobRoleName = teamMember.Employee.JobRole.Name;
|
||||
}
|
||||
|
||||
result.Add(result1);
|
||||
}
|
||||
|
||||
result.Sort(delegate (EmployeeAttendanceVM x, EmployeeAttendanceVM y) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
[Route("record")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user