diff --git a/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs b/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs index 06c292998..3f8f19061 100644 --- a/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs @@ -215,7 +215,7 @@ namespace IRaCIS.Core.Application.Service if (!attachment.Path.Contains(attachment.DoctorId.ToString())) { - var attachmentData= await _attachmentrepository.FirstOrDefaultAsync(a => a.Id == attachment.Id); + var attachmentData= await _attachmentrepository.Where(a => a.Id == attachment.Id).FirstNotNullAsync(); var fileName= attachmentData.Path.Split("/").Last(); @@ -228,7 +228,7 @@ namespace IRaCIS.Core.Application.Service if (attachment.DoctorId != null) { - await _attachmentrepository.DeleteFromQueryAsync(a => a.DoctorId == attachment.DoctorId && a.Type == attachment.Type); + await _attachmentrepository.DeleteFromQueryAsync(a =>a.Id!=attachment.Id&& a.DoctorId == attachment.DoctorId && a.Type == attachment.Type); } attachment.UpdateTime = DateTime.Now;