Exemplo n.º 1
0
        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."));
            }
        }
Exemplo n.º 2
0
        /// <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));
            }
        }
Exemplo n.º 3
0
        /// <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));
        }