From d41c49af7bb1a00163da54ce2ebc5358f7c29c02 Mon Sep 17 00:00:00 2001 From: "ashutosh.nehete" Date: Thu, 18 Sep 2025 15:55:45 +0530 Subject: [PATCH] Removed the Document ID Uniqueness --- .../Controllers/DocumentController.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Marco.Pms.Services/Controllers/DocumentController.cs b/Marco.Pms.Services/Controllers/DocumentController.cs index f450c41..8bd52cd 100644 --- a/Marco.Pms.Services/Controllers/DocumentController.cs +++ b/Marco.Pms.Services/Controllers/DocumentController.cs @@ -705,13 +705,6 @@ namespace Marco.Pms.Services.Controllers return NotFound(ApiResponse.ErrorResponse($"{(entityType == EmployeeEntity ? "Employee" : "Project")} Not Found", "Entity not found in database", 404)); } - var isDocumentExist = await _context.DocumentAttachments.AnyAsync(da => da.DocumentId == model.DocumentId && da.TenantId == tenantId); - if (isDocumentExist) - { - _logger.LogWarning("{DocumentId} is already existed in database", model.DocumentId ?? string.Empty); - return StatusCode(409, ApiResponse.ErrorResponse("Document already existed", "Document already existed in database", 409)); - } - // Map DTO to DB entity var attachment = _mapper.Map(model); attachment.UploadedAt = DateTime.UtcNow; @@ -1108,13 +1101,6 @@ namespace Marco.Pms.Services.Controllers return NotFound(ApiResponse.ErrorResponse($"{(entityType == EmployeeEntity ? "Employee" : "Project")} Not Found", "Entity not found in database", 404)); } - var isDocumentExist = await _context.DocumentAttachments.AnyAsync(da => da.Id != model.Id && da.DocumentId == model.DocumentId && da.TenantId == tenantId); - if (isDocumentExist) - { - _logger.LogWarning("{DocumentId} is already existed in database", model.DocumentId ?? string.Empty); - return StatusCode(409, ApiResponse.ErrorResponse("Document already existed", "Document already existed in database", 409)); - } - // Prepare for versioning var oldVersionMapping = await _context.AttachmentVersionMappings .FirstOrDefaultAsync(av => av.ChildAttachmentId == oldAttachment.Id && av.TenantId == tenantId);