Issues_June_3W #99
@ -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,
|
||||
|
@ -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 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; }
|
||||
|
@ -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<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;
|
||||
@ -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<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));
|
||||
@ -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<ContactNoteListVM> noteVMS = notes
|
||||
.Select(cn => cn.ToContactNoteListVMFromContactNote())
|
||||
List<ContactNoteVM> 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user