Document_Manager #129

Merged
ashutosh.nehete merged 83 commits from Document_Manager into main 2025-09-11 04:12:01 +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); 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 // Update bucket properties safely
bucket.Name = bucketDto.Name ?? string.Empty; bucket.Name = bucketDto.Name ?? string.Empty;
bucket.Description = bucketDto.Description ?? 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.EmployeeIds = employeeBuckets.Where(eb => eb.BucketId == bucket.Id).Select(eb => eb.EmployeeId).ToList();
bucketVM.NumberOfContacts = contactBuckets.Count; 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); _logger.LogInfo("Employee ID {LoggedInEmployeeId} successfully updated bucket ID {BucketId}.", loggedInEmployee.Id, bucket.Id);
return ApiResponse<object>.SuccessResponse(bucketVM, "Bucket updated successfully", 200); return ApiResponse<object>.SuccessResponse(bucketVM, "Bucket updated successfully", 200);
@ -2216,6 +2226,8 @@ namespace Marco.Pms.Services.Service
"Permission denied", 403); "Permission denied", 403);
} }
var bucketObject = _updateLogsHelper.EntityToBsonDocument(bucket);
// Remove related employee bucket mappings // Remove related employee bucket mappings
_context.EmployeeBucketMappings.RemoveRange(employeeBucketMappings); _context.EmployeeBucketMappings.RemoveRange(employeeBucketMappings);
// Remove the bucket itself // 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.", _logger.LogInfo("Employee {EmployeeId} deleted bucket {BucketId} along with related employee bucket mappings.",
loggedInEmployee.Id, bucket.Id); 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); return ApiResponse<object>.SuccessResponse(new { }, "Bucket deleted successfully", 200);
} }
catch (Exception ex) catch (Exception ex)