Implemented an API to update Buckets for grouping contacts. #68

Merged
vikas.nale merged 1 commits from Ashutosh_Task#250_Update_Bucket into Feature_Directory 2025-05-23 05:45:38 +00:00
Collaborator
  • Get Tenant and Employee Info:
    • Get the current tenant ID using _userHelper.GetTenantId().
    • Get the currently logged-in employee using _userHelper.GetCurrentEmployeeAsync().
  • Validate Input:
    • Ensure bucketDto is not null and that the provided id matches bucketDto.Id.
    • If invalid, log a warning and return a 400 Bad Request error response with a message: "User sent empty Payload".
  • Fetch Bucket:
    • Look for the bucket in the database where:
      • Id matches bucketDto.Id
      • TenantId matches the current tenant
    • If the bucket is not found:
      • Log a warning that the employee tried to update a non-existent bucket.
      • Return a 404 Not Found error response with the message: "Bucket not found".
  • Update Bucket Fields:
    • Set the bucket’s Name and Description from bucketDto, using empty strings as fallbacks for null values.
  • Log the Update:
    • Create a new DirectoryUpdateLog entry capturing:
      • The reference ID (bucket ID)
      • The employee who made the change
      • The update timestamp (DateTime.UtcNow)
    • Add the log to the database context.
  • Save Changes:
    • Persist the changes to the database with SaveChangesAsync().
  • Prepare Response:
    • Convert the updated bucket to a BucketVM (view model).
    • Log a success message indicating the update and employee ID.
    • Return a 200 OK success response with the updated bucket data.
- **Get Tenant and Employee Info**: - Get the current tenant ID using _userHelper.GetTenantId(). - Get the currently logged-in employee using _userHelper.GetCurrentEmployeeAsync(). - **Validate Input**: - Ensure bucketDto is not null and that the provided id matches bucketDto.Id. - If invalid, log a warning and return a 400 Bad Request error response with a message: "User sent empty Payload". - **Fetch Bucket**: - Look for the bucket in the database where: - Id matches bucketDto.Id - TenantId matches the current tenant - If the bucket is not found: - Log a warning that the employee tried to update a non-existent bucket. - Return a 404 Not Found error response with the message: "Bucket not found". - **Update Bucket Fields**: - Set the bucket’s Name and Description from bucketDto, using empty strings as fallbacks for null values. - **Log the Update**: - Create a new DirectoryUpdateLog entry capturing: - The reference ID (bucket ID) - The employee who made the change - The update timestamp (DateTime.UtcNow) - Add the log to the database context. - **Save Changes**: - Persist the changes to the database with SaveChangesAsync(). - **Prepare Response**: - Convert the updated bucket to a BucketVM (view model). - Log a success message indicating the update and employee ID. - Return a 200 OK success response with the updated bucket data.
ashutosh.nehete added 1 commit 2025-05-22 14:19:47 +00:00
vikas.nale merged commit 4801229f1e into Feature_Directory 2025-05-23 05:45:38 +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#68
No description provided.