Added conatct name nd organization name in all contact note VMs
This commit is contained in:
parent
90c5308d76
commit
d12f8ed0fb
@ -229,20 +229,6 @@ namespace Marco.Pms.Model.Mapper
|
|||||||
public static ContactNoteVM ToContactNoteVMFromContactNote(this ContactNote note)
|
public static ContactNoteVM ToContactNoteVMFromContactNote(this ContactNote note)
|
||||||
{
|
{
|
||||||
return new ContactNoteVM
|
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,
|
Id = note.Id,
|
||||||
Note = note.Note,
|
Note = note.Note,
|
||||||
|
@ -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; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,6 +6,8 @@ namespace Marco.Pms.Model.ViewModels.Directory
|
|||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public string Note { get; set; } = string.Empty;
|
public string Note { get; set; } = string.Empty;
|
||||||
|
public string? ContactName { get; set; }
|
||||||
|
public string? OrganizationName { get; set; }
|
||||||
public DateTime CreatedAt { get; set; }
|
public DateTime CreatedAt { get; set; }
|
||||||
public BasicEmployeeVM? CreatedBy { get; set; }
|
public BasicEmployeeVM? CreatedBy { get; set; }
|
||||||
public DateTime? UpdatedAt { get; set; }
|
public DateTime? UpdatedAt { get; set; }
|
||||||
|
@ -953,7 +953,7 @@ namespace Marco.Pms.Services.Helpers
|
|||||||
if (!assignedBucketIds.Any())
|
if (!assignedBucketIds.Any())
|
||||||
{
|
{
|
||||||
_logger.LogInfo("GetListOFAllNotes: User {EmployeeId} has no assigned buckets. Returning empty list.", loggedInEmployee.Id);
|
_logger.LogInfo("GetListOFAllNotes: User {EmployeeId} has no assigned buckets. Returning empty list.", loggedInEmployee.Id);
|
||||||
return ApiResponse<object>.SuccessResponse(new { CurrentPage = pageNumber, TotalPages = 0, Data = new List<ContactNoteListVM>() }, "No notes found based on assigned buckets.", 200);
|
return ApiResponse<object>.SuccessResponse(new { CurrentPage = pageNumber, TotalPages = 0, Data = new List<ContactNoteVM>() }, "No notes found based on assigned buckets.", 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Guid>? contactIds = null;
|
List<Guid>? contactIds = null;
|
||||||
@ -976,7 +976,7 @@ namespace Marco.Pms.Services.Helpers
|
|||||||
if (!contactIds.Any())
|
if (!contactIds.Any())
|
||||||
{
|
{
|
||||||
_logger.LogInfo("GetListOFAllNotes: No contacts found for assigned buckets for user {EmployeeId}. Returning empty list.", loggedInEmployee.Id);
|
_logger.LogInfo("GetListOFAllNotes: No contacts found for assigned buckets for user {EmployeeId}. Returning empty list.", loggedInEmployee.Id);
|
||||||
return ApiResponse<object>.SuccessResponse(new { CurrentPage = pageNumber, TotalPages = 0, Data = new List<ContactNoteListVM>() }, "No notes found for associated contacts.", 200);
|
return ApiResponse<object>.SuccessResponse(new { CurrentPage = pageNumber, TotalPages = 0, Data = new List<ContactNoteVM>() }, "No notes found for associated contacts.", 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
notesQuery = notesQuery.Where(cn => contactIds.Contains(cn.ContactId));
|
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
|
// This mapping is done in memory because ToBasicEmployeeVMFromEmployee() is likely a C# method
|
||||||
// that cannot be translated to SQL by Entity Framework.
|
// that cannot be translated to SQL by Entity Framework.
|
||||||
|
|
||||||
List<ContactNoteListVM> noteVMS = notes
|
List<ContactNoteVM> noteVMS = notes
|
||||||
.Select(cn => cn.ToContactNoteListVMFromContactNote())
|
.Select(cn => cn.ToContactNoteVMFromContactNote())
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var response = new
|
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);
|
Contact? contact = await _context.Contacts.FirstOrDefaultAsync(c => c.Id == noteDto.ContactId && c.IsActive && c.TenantId == tenantId);
|
||||||
if (contact != null)
|
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)
|
if (contactNote != null)
|
||||||
{
|
{
|
||||||
contactNote.Note = noteDto.Note;
|
contactNote.Note = noteDto.Note;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user