Removed the Document ID Uniqueness
This commit is contained in:
parent
a10b24523e
commit
d41c49af7b
@ -705,13 +705,6 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
return NotFound(ApiResponse<object>.ErrorResponse($"{(entityType == EmployeeEntity ? "Employee" : "Project")} Not Found", "Entity not found in database", 404));
|
return NotFound(ApiResponse<object>.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<object>.ErrorResponse("Document already existed", "Document already existed in database", 409));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Map DTO to DB entity
|
// Map DTO to DB entity
|
||||||
var attachment = _mapper.Map<DocumentAttachment>(model);
|
var attachment = _mapper.Map<DocumentAttachment>(model);
|
||||||
attachment.UploadedAt = DateTime.UtcNow;
|
attachment.UploadedAt = DateTime.UtcNow;
|
||||||
@ -1108,13 +1101,6 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
return NotFound(ApiResponse<object>.ErrorResponse($"{(entityType == EmployeeEntity ? "Employee" : "Project")} Not Found", "Entity not found in database", 404));
|
return NotFound(ApiResponse<object>.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<object>.ErrorResponse("Document already existed", "Document already existed in database", 409));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare for versioning
|
// Prepare for versioning
|
||||||
var oldVersionMapping = await _context.AttachmentVersionMappings
|
var oldVersionMapping = await _context.AttachmentVersionMappings
|
||||||
.FirstOrDefaultAsync(av => av.ChildAttachmentId == oldAttachment.Id && av.TenantId == tenantId);
|
.FirstOrDefaultAsync(av => av.ChildAttachmentId == oldAttachment.Id && av.TenantId == tenantId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user