Added an API to add a note to specific contact
This commit is contained in:
parent
70ec3b6a44
commit
a752bc39fe
@ -646,7 +646,28 @@ namespace Marco.Pms.Services.Helpers
|
|||||||
_logger.LogWarning("Employee with ID {LoggedInEmployeeId} attempted to fetch a list notes from contact with ID {ContactId}, but the contact was not found in the database.", LoggedInEmployee.Id, id);
|
_logger.LogWarning("Employee with ID {LoggedInEmployeeId} attempted to fetch a list notes from contact with ID {ContactId}, but the contact was not found in the database.", LoggedInEmployee.Id, id);
|
||||||
return ApiResponse<object>.ErrorResponse("Contact not found", "Contact not found", 404);
|
return ApiResponse<object>.ErrorResponse("Contact not found", "Contact not found", 404);
|
||||||
}
|
}
|
||||||
|
public async Task<ApiResponse<object>> CreateContactNote(CreateContactNoteDto noteDto)
|
||||||
|
{
|
||||||
|
Guid tenantId = _userHelper.GetTenantId();
|
||||||
|
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
|
if (noteDto != null)
|
||||||
|
{
|
||||||
|
Contact? contact = await _context.Contacts.FirstOrDefaultAsync(c => c.Id == noteDto.ContactId && c.IsActive && c.TenantId == tenantId);
|
||||||
|
if (contact != null)
|
||||||
|
{
|
||||||
|
ContactNote note = noteDto.ToContactNoteFromCreateContactNoteDto(tenantId, LoggedInEmployee.Id);
|
||||||
|
_context.ContactNotes.Add(note);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
ContactNoteVM noteVM = note.ToContactNoteVMFromContactNote();
|
||||||
|
_logger.LogInfo("Employee {EmployeeId} Added note at contact {ContactId}", LoggedInEmployee.Id, contact.Id);
|
||||||
|
return ApiResponse<object>.SuccessResponse(noteVM, "Note added successfully", 200);
|
||||||
|
}
|
||||||
|
_logger.LogWarning("Employee with ID {LoggedInEmployeeId} attempted to add a note to contact with ID {ContactId}, but the contact was not found in the database.", LoggedInEmployee.Id, noteDto.ContactId);
|
||||||
|
return ApiResponse<object>.ErrorResponse("Contact not found", "Contact not found", 404);
|
||||||
|
}
|
||||||
|
_logger.LogWarning("Employee with ID {LoggedInEmployeeId} sended empty payload", LoggedInEmployee.Id);
|
||||||
|
return ApiResponse<object>.ErrorResponse("User Send empty Payload", "User Send empty Payload", 400);
|
||||||
|
}
|
||||||
public async Task<ApiResponse<object>> UpdateContactNote(Guid id, UpdateContactNoteDto noteDto)
|
public async Task<ApiResponse<object>> UpdateContactNote(Guid id, UpdateContactNoteDto noteDto)
|
||||||
{
|
{
|
||||||
Guid tenantId = _userHelper.GetTenantId();
|
Guid tenantId = _userHelper.GetTenantId();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user