public async void Deletes(List <Guid> ids) { using (var dbContextReadOnlyScope = _dbContextScopeFactory.Create()) { foreach (var id in ids) { var attchment = _attachmentRepository.GetById(id); _attachmentRepository.Delete(attchment); } await dbContextReadOnlyScope.SaveChangesAsync(); } }
/// <summary> /// 删除附件 /// </summary> /// <param name="attachment">附件</param> public void Delete(T attachment) { DeleteStoredFile(attachment); EventBus <T> .Instance().OnBefore(attachment, new CommonEventArgs(EventOperationType.Instance().Delete())); attachmentRepository.Delete(attachment); EventBus <T> .Instance().OnAfter(attachment, new CommonEventArgs(EventOperationType.Instance().Delete())); }
public Tuple <bool, string> Delete(long id) { try { _attachmentRepository.Delete(x => x.Id == id); _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "عملیات حذف انجام شد")); } catch (Exception) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات")); } }
public Tuple <bool, string> Delete(long requestId) { try { using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { _cartableRepository.Delete(c => c.RequestId == requestId); _commissionRepository.Delete(c => c.RequestId == requestId); _councilRepository.Delete(c => c.RequestId == requestId); _attachmentRepository.Delete(a => a.RequestId == requestId); _voteRepository.Delete(v => v.RequestId == requestId); _archiveRepository.Delete(a => a.RequestId == requestId); _commissionSpecialEducationRepository.Delete(c => c.CommissionId == requestId); _requestRepository.Delete(r => r.Id == requestId); _unitOfWork.SaveChanges(); scope.Complete(); return(new Tuple <bool, string>(true, "عملیات حذف با موفقیت انجام شده است")); } } catch (Exception ex) { return(new Tuple <bool, string>(false, "عملیات حذف با مشکل مواجه شده است")); } }
private async void DeleteAttachment(Attachment obj) { Attachments.Remove(obj); await AttachmentRepository.Delete(obj.Id); }
public ActionResult Delete(int id, int courseId) { var deletedAttachment = _repository.Delete(id); return(RedirectToAction("Index", "Attachments", new { employeeId = id, courseId = courseId })); }