public ActionConfirmation Delete(int id) { Org orgToDelete = _orgRepository.Get(id); if (orgToDelete != null) { _orgRepository.Delete(orgToDelete); try { _orgRepository.DbContext.CommitChanges(); return(ActionConfirmation.CreateSuccessConfirmation( "The org was successfully deleted.")); } catch { _orgRepository.DbContext.RollbackTransaction(); return(ActionConfirmation.CreateFailureConfirmation( "A problem was encountered preventing the org from being deleted. " + "Another item likely depends on this org.")); } } else { return(ActionConfirmation.CreateFailureConfirmation( "The org could not be found for deletion. It may already have been deleted.")); } }
/// <summary> /// 删除指定ID的部门及其所有子部门 /// </summary> public void DelOrg(Guid[] ids) { var delOrg = _repository.Find(u => ids.Contains(u.Id)).ToList(); foreach (var org in delOrg) { _repository.Delete(u => u.CascadeId.Contains(org.CascadeId)); } }
/// <summary> /// 删除指定ID的部门及其所有子部门 /// </summary> public void DelOrg(int id) { var delOrg = _repository.FindSingle(u => u.Id == id); if (delOrg == null) { return; } _repository.Delete(u => u.CascadeId.Contains(delOrg.CascadeId)); }