Feature_Directory #90

Merged
vikas.nale merged 501 commits from Feature_Directory into main 2025-06-10 14:44:36 +00:00
Showing only changes of commit d60608e544 - Show all commits

View File

@ -925,11 +925,25 @@ namespace Marco.Pms.Services.Helpers
{
notes = await _context.ContactNotes.Where(n => n.ContactId == contact.Id && n.TenantId == tenantId).ToListAsync();
}
var noteIds = notes.Select(n => n.Id).ToList();
List<DirectoryUpdateLog>? updateLogs = await _context.DirectoryUpdateLogs.Include(l => l.Employee).Where(l => noteIds.Contains(l.RefereanceId)).ToListAsync();
List<ContactNoteVM>? noteVMs = new List<ContactNoteVM>();
foreach (var note in notes)
{
ContactNoteVM noteVM = note.ToContactNoteVMFromContactNote();
DirectoryUpdateLog? updateLog = updateLogs.Where(l => l.RefereanceId == note.Id).OrderByDescending(l => l.UpdateAt).FirstOrDefault();
if (updateLog != null)
{
noteVM.UpdatedAt = updateLog.UpdateAt;
noteVM.UpdatedBy = updateLog.Employee != null ? updateLog.Employee.ToBasicEmployeeVMFromEmployee() : null;
}
else
{
noteVM.UpdatedAt = note.CreatedAt;
noteVM.UpdatedBy = note.Createdby != null ? note.Createdby.ToBasicEmployeeVMFromEmployee() : null;
}
noteVMs.Add(noteVM);
}
_logger.LogInfo("{count} contact-notes record from contact {ContactId} fetched by Employee {EmployeeId}", noteVMs.Count, id, LoggedInEmployee.Id);
return ApiResponse<object>.SuccessResponse(noteVMs, $"{noteVMs.Count} contact-notes record fetched successfully", 200);