Implemented an API to update Contact Category Master #69

Merged
vikas.nale merged 1 commits from Ashutosh_Task#233_Update_Contact_Category into Feature_Directory 2025-05-23 05:45:53 +00:00
Collaborator
  • Get Tenant and Employee Info:
    • Get the current tenant ID using _userHelper.GetTenantId().
    • Get the currently logged-in employee with _userHelper.GetCurrentEmployeeAsync().
  • Input Validation:
    • Check that contactCategoryDto is not null and that its Id matches the provided id from the route.
    • If this check fails:
      • Log a warning that an empty or invalid payload was received.
      • Return a 400 Bad Request error response: "User Send empty Payload".
  • Fetch Category from Database:
    • Try to find a ContactCategoryMaster entry that matches:
      • The provided id
      • The current tenant's ID
    • If not found:
      • Log a warning that the category does not exist.
      • Return a 404 Not Found error response: "Category not found".
  • Update the Category:
    • If the category is found:
      • Update its Name and Description with values from contactCategoryDto, using empty strings if they are null.
  • Log the Update:
    • Add an entry to the DirectoryUpdateLogs table with:
    • RefereanceId as the category ID
    • UpdatedById as the employee ID
    • UpdateAt as the current UTC time
  • Save Changes:
    • Persist all changes to the database using SaveChangesAsync().
  • Build and Return Response:
    • Convert the updated category to a ContactCategoryVM.
    • Log an info mssage indicating the update with employee and category IDs.
    • Return a 200 OK success response with the updated category data.
- **Get Tenant and Employee Info**: - Get the current tenant ID using _userHelper.GetTenantId(). - Get the currently logged-in employee with _userHelper.GetCurrentEmployeeAsync(). - **Input Validation**: - Check that contactCategoryDto is not null and that its Id matches the provided id from the route. - If this check fails: - Log a warning that an empty or invalid payload was received. - Return a 400 Bad Request error response: "User Send empty Payload". - **Fetch Category from Database**: - Try to find a ContactCategoryMaster entry that matches: - The provided id - The current tenant's ID - If not found: - Log a warning that the category does not exist. - Return a 404 Not Found error response: "Category not found". - **Update the Category**: - If the category is found: - Update its Name and Description with values from contactCategoryDto, using empty strings if they are null. - **Log the Update**: - Add an entry to the DirectoryUpdateLogs table with: - RefereanceId as the category ID - UpdatedById as the employee ID - UpdateAt as the current UTC time - **Save Changes**: - Persist all changes to the database using SaveChangesAsync(). - **Build and Return Response**: - Convert the updated category to a ContactCategoryVM. - Log an info mssage indicating the update with employee and category IDs. - Return a 200 OK success response with the updated category data.
ashutosh.nehete added 1 commit 2025-05-22 14:57:42 +00:00
vikas.nale merged commit bcca8cab80 into Feature_Directory 2025-05-23 05:45:53 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/marco.pms.api#69
No description provided.