From d12f8ed0fbffad4f11ff1b7db3efb4206c25e3eb Mon Sep 17 00:00:00 2001 From: "ashutosh.nehete" Date: Fri, 27 Jun 2025 11:50:51 +0530 Subject: [PATCH] Added conatct name nd organization name in all contact note VMs --- Marco.Pms.Model/Mapper/DirectoryMapper.cs | 14 -------------- .../ViewModels/Directory/ContactNoteListVM.cs | 18 ------------------ .../ViewModels/Directory/ContactNoteVM.cs | 2 ++ Marco.Pms.Services/Helpers/DirectoryHelper.cs | 10 +++++----- 4 files changed, 7 insertions(+), 37 deletions(-) delete mode 100644 Marco.Pms.Model/ViewModels/Directory/ContactNoteListVM.cs diff --git a/Marco.Pms.Model/Mapper/DirectoryMapper.cs b/Marco.Pms.Model/Mapper/DirectoryMapper.cs index 9f7d2dc..b175cb7 100644 --- a/Marco.Pms.Model/Mapper/DirectoryMapper.cs +++ b/Marco.Pms.Model/Mapper/DirectoryMapper.cs @@ -229,20 +229,6 @@ namespace Marco.Pms.Model.Mapper public static ContactNoteVM ToContactNoteVMFromContactNote(this ContactNote note) { return new ContactNoteVM - { - Id = note.Id, - Note = note.Note, - ContactId = note.ContactId, - CreatedAt = note.CreatedAt, - UpdatedAt = note.UpdatedAt, - CreatedBy = note.Createdby != null ? note.Createdby.ToBasicEmployeeVMFromEmployee() : null, - UpdatedBy = note.UpdatedBy != null ? note.UpdatedBy.ToBasicEmployeeVMFromEmployee() : null, - IsActive = note.IsActive - }; - } - public static ContactNoteListVM ToContactNoteListVMFromContactNote(this ContactNote note) - { - return new ContactNoteListVM { Id = note.Id, Note = note.Note, diff --git a/Marco.Pms.Model/ViewModels/Directory/ContactNoteListVM.cs b/Marco.Pms.Model/ViewModels/Directory/ContactNoteListVM.cs deleted file mode 100644 index 68451ed..0000000 --- a/Marco.Pms.Model/ViewModels/Directory/ContactNoteListVM.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Marco.Pms.Model.ViewModels.Activities; - -namespace Marco.Pms.Model.ViewModels.Directory -{ - public class ContactNoteListVM - { - public Guid Id { get; set; } - public string? Note { get; set; } - public string? ContactName { get; set; } - public string? OrganizationName { get; set; } - public DateTime CreatedAt { get; set; } - public BasicEmployeeVM? CreatedBy { get; set; } - public DateTime? UpdatedAt { get; set; } - public BasicEmployeeVM? UpdatedBy { get; set; } - public Guid ContactId { get; set; } - public bool IsActive { get; set; } - } -} diff --git a/Marco.Pms.Model/ViewModels/Directory/ContactNoteVM.cs b/Marco.Pms.Model/ViewModels/Directory/ContactNoteVM.cs index c00b0de..198fa85 100644 --- a/Marco.Pms.Model/ViewModels/Directory/ContactNoteVM.cs +++ b/Marco.Pms.Model/ViewModels/Directory/ContactNoteVM.cs @@ -6,6 +6,8 @@ namespace Marco.Pms.Model.ViewModels.Directory { public Guid Id { get; set; } public string Note { get; set; } = string.Empty; + public string? ContactName { get; set; } + public string? OrganizationName { get; set; } public DateTime CreatedAt { get; set; } public BasicEmployeeVM? CreatedBy { get; set; } public DateTime? UpdatedAt { get; set; } diff --git a/Marco.Pms.Services/Helpers/DirectoryHelper.cs b/Marco.Pms.Services/Helpers/DirectoryHelper.cs index 301c708..bafa36f 100644 --- a/Marco.Pms.Services/Helpers/DirectoryHelper.cs +++ b/Marco.Pms.Services/Helpers/DirectoryHelper.cs @@ -953,7 +953,7 @@ namespace Marco.Pms.Services.Helpers if (!assignedBucketIds.Any()) { _logger.LogInfo("GetListOFAllNotes: User {EmployeeId} has no assigned buckets. Returning empty list.", loggedInEmployee.Id); - return ApiResponse.SuccessResponse(new { CurrentPage = pageNumber, TotalPages = 0, Data = new List() }, "No notes found based on assigned buckets.", 200); + return ApiResponse.SuccessResponse(new { CurrentPage = pageNumber, TotalPages = 0, Data = new List() }, "No notes found based on assigned buckets.", 200); } List? contactIds = null; @@ -976,7 +976,7 @@ namespace Marco.Pms.Services.Helpers if (!contactIds.Any()) { _logger.LogInfo("GetListOFAllNotes: No contacts found for assigned buckets for user {EmployeeId}. Returning empty list.", loggedInEmployee.Id); - return ApiResponse.SuccessResponse(new { CurrentPage = pageNumber, TotalPages = 0, Data = new List() }, "No notes found for associated contacts.", 200); + return ApiResponse.SuccessResponse(new { CurrentPage = pageNumber, TotalPages = 0, Data = new List() }, "No notes found for associated contacts.", 200); } notesQuery = notesQuery.Where(cn => contactIds.Contains(cn.ContactId)); @@ -1014,8 +1014,8 @@ namespace Marco.Pms.Services.Helpers // This mapping is done in memory because ToBasicEmployeeVMFromEmployee() is likely a C# method // that cannot be translated to SQL by Entity Framework. - List noteVMS = notes - .Select(cn => cn.ToContactNoteListVMFromContactNote()) + List noteVMS = notes + .Select(cn => cn.ToContactNoteVMFromContactNote()) .ToList(); var response = new @@ -1096,7 +1096,7 @@ namespace Marco.Pms.Services.Helpers Contact? contact = await _context.Contacts.FirstOrDefaultAsync(c => c.Id == noteDto.ContactId && c.IsActive && c.TenantId == tenantId); if (contact != null) { - ContactNote? contactNote = await _context.ContactNotes.Include(cn => cn.Createdby).FirstOrDefaultAsync(n => n.Id == noteDto.Id && n.ContactId == contact.Id && n.IsActive); + ContactNote? contactNote = await _context.ContactNotes.Include(cn => cn.Createdby).Include(cn => cn.Contact).FirstOrDefaultAsync(n => n.Id == noteDto.Id && n.ContactId == contact.Id && n.IsActive); if (contactNote != null) { contactNote.Note = noteDto.Note;