Directory_Refactor #128

Merged
ashutosh.nehete merged 22 commits from Directory_Refactor into Document_Manager 2025-09-09 11:03:46 +00:00
Showing only changes of commit 4a78bb8074 - Show all commits

View File

@ -1945,6 +1945,8 @@ namespace Marco.Pms.Services.Service
return ApiResponse<object>.ErrorResponse("You don't have permission to access this bucket", "You don't have permission to access this bucket", 403);
}
var bucketObject = _updateLogsHelper.EntityToBsonDocument(bucket);
// Update bucket properties safely
bucket.Name = bucketDto.Name ?? string.Empty;
bucket.Description = bucketDto.Description ?? string.Empty;
@ -1970,6 +1972,14 @@ namespace Marco.Pms.Services.Service
bucketVM.EmployeeIds = employeeBuckets.Where(eb => eb.BucketId == bucket.Id).Select(eb => eb.EmployeeId).ToList();
bucketVM.NumberOfContacts = contactBuckets.Count;
await _updateLogsHelper.PushToUpdateLogsAsync(new UpdateLogsObject
{
EntityId = bucket.Id.ToString(),
UpdatedById = loggedInEmployee.Id.ToString(),
OldObject = bucketObject,
UpdatedAt = DateTime.UtcNow
}, bucketCollection);
_logger.LogInfo("Employee ID {LoggedInEmployeeId} successfully updated bucket ID {BucketId}.", loggedInEmployee.Id, bucket.Id);
return ApiResponse<object>.SuccessResponse(bucketVM, "Bucket updated successfully", 200);
@ -2216,6 +2226,8 @@ namespace Marco.Pms.Services.Service
"Permission denied", 403);
}
var bucketObject = _updateLogsHelper.EntityToBsonDocument(bucket);
// Remove related employee bucket mappings
_context.EmployeeBucketMappings.RemoveRange(employeeBucketMappings);
// Remove the bucket itself
@ -2233,6 +2245,14 @@ namespace Marco.Pms.Services.Service
_logger.LogInfo("Employee {EmployeeId} deleted bucket {BucketId} along with related employee bucket mappings.",
loggedInEmployee.Id, bucket.Id);
await _updateLogsHelper.PushToUpdateLogsAsync(new UpdateLogsObject
{
EntityId = bucket.Id.ToString(),
UpdatedById = loggedInEmployee.Id.ToString(),
OldObject = bucketObject,
UpdatedAt = DateTime.UtcNow
}, bucketCollection);
return ApiResponse<object>.SuccessResponse(new { }, "Bucket deleted successfully", 200);
}
catch (Exception ex)