public CommandResult Delete(Role info) { if (!info.CanDelete) { return(new CommandResult(ResultCode.Fail, string.Format(Resource1.RoleBll_CannotDelete, info.Name))); } else { OperatorBll bll = new OperatorBll(_RepoUri); QueryResultList <Operator> result = bll.GetAllOperators(); if (result.Result == ResultCode.Successful && result.QueryObjects.Exists(opt => opt.RoleID == info.ID)) { return(new CommandResult(ResultCode.Fail, string.Format(Resource1.RoleBll_RoleBeUsed, info.ID, info.ID))); } } return(provider.Delete(info)); }
public CommandResult Delete(RoleInfo info) { if (!info.CanDelete) { throw new InvalidOperationException(string.Format(Resource1.RoleBll_CannotDelete, info.Name)); } else { OperatorBll bll = new OperatorBll(_RepoUri); OperatorSearchCondition search = new OperatorSearchCondition { RoleID = info.RoleID }; QueryResultList <OperatorInfo> result = bll.GetOperators(search); if (result.Result == ResultCode.Successful && result.QueryObjects.Count > 0) { throw new InvalidOperationException(string.Format(Resource1.RoleBll_RoleBeUsed, info.RoleID, info.RoleID)); } } return(provider.Delete(info)); }