Sending the project degination in place of employee degination in allocation history API
This commit is contained in:
parent
897a998b27
commit
d113fc3c3d
11
Marco.Pms.Model/ViewModels/Projects/ProjectHisteryVM.cs
Normal file
11
Marco.Pms.Model/ViewModels/Projects/ProjectHisteryVM.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace Marco.Pms.Model.ViewModels.Projects
|
||||
{
|
||||
public class ProjectHisteryVM
|
||||
{
|
||||
public string? ProjectName { get; set; }
|
||||
public string? ProjectShortName { get; set; }
|
||||
public DateTime AssignedDate { get; set; }
|
||||
public DateTime? RemovedDate { get; set; }
|
||||
public string? Designation { get; set; }
|
||||
}
|
||||
}
|
@ -918,17 +918,35 @@ namespace Marco.Pms.Services.Service
|
||||
ProjectShortName = pa.Project.ShortName,
|
||||
AssignedDate = pa.AllocationDate,
|
||||
RemovedDate = pa.ReAllocationDate,
|
||||
Designation = pa.Employee!.JobRole!.Name
|
||||
Designation = pa.Employee!.JobRole!.Name,
|
||||
DesignationId = pa.JobRoleId
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var designationIds = projectAllocation.Select(pa => pa.DesignationId).ToList();
|
||||
|
||||
var designations = await _context.JobRoles.Where(jr => designationIds.Contains(jr.Id)).ToListAsync();
|
||||
|
||||
var response = projectAllocation.Select(pa =>
|
||||
{
|
||||
var designation = designations.FirstOrDefault(jr => jr.Id == pa.DesignationId);
|
||||
return new ProjectHisteryVM
|
||||
{
|
||||
ProjectName = pa.ProjectName,
|
||||
ProjectShortName = pa.ProjectShortName,
|
||||
AssignedDate = pa.AssignedDate,
|
||||
RemovedDate = pa.RemovedDate,
|
||||
Designation = designation?.Name
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
// Log successful retrieval including count of records
|
||||
_logger.LogInfo("Successfully fetched {Count} projects for EmployeeId: {EmployeeId}",
|
||||
projectAllocation.Count, employeeId);
|
||||
|
||||
return ApiResponse<object>.SuccessResponse(
|
||||
projectAllocation,
|
||||
$"{projectAllocation.Count} project assignments fetched for employee.",
|
||||
response,
|
||||
$"{response.Count} project assignments fetched for employee.",
|
||||
200);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -49,6 +49,6 @@
|
||||
"MongoDB": {
|
||||
"SerilogDatabaseUrl": "mongodb://localhost:27017/DotNetLogs",
|
||||
"ConnectionString": "mongodb://localhost:27017/MarcoBMS_Caches?socketTimeoutMS=500&serverSelectionTimeoutMS=500&connectTimeoutMS=500",
|
||||
"ModificationConnectionString": "mongodb://localhost:27017/ModificationLog?socketTimeoutMS=500&serverSelectionTimeoutMS=500&connectTimeoutMS=500"
|
||||
"ModificationConnectionString": "mongodb://localhost:27017/ModificationLog?socketTimeoutMS=500&serverSelectionTimeoutMS=500&connectTimeoutMS=500&replicaSet=rs01&directConnection=true"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user