/// <summary> /// 删除实体对象 /// </summary> /// <param name="id">实体对象Id</param> /// <param name="status">操作状态</param> public virtual OperateStatus Delete(Guid id) { //操作状态信息 var status = new OperateStatus { IsSuccessful = false }; if (id == Guid.Empty) { status.Message = "该数据不允许删除或不存在!"; return(status); } T entity = GetById(id); if (entity == null) { status.Message = "删除的数据不存在"; } else { status = repository.Delete(entity); if (status.IsSuccessful) { //指定成功默认返回结果值 status.Message = "成功"; } } return(status); }
/// <summary> /// 删除单条数据 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual JsonModel Delete(int id) { JsonModel jsonModel = null; try { bool result = CurrentDal.Delete(CurrentEntity, id); jsonModel = new JsonModel() { errNum = 0, errMsg = "success", retData = result }; return(jsonModel); } catch (Exception ex) { LogHelper.Error(ex); jsonModel = new JsonModel() { errNum = 400, errMsg = ex.Message, retData = "" }; return(jsonModel); } }
public async Task <int> SaveRolePermissions(int roleId, List <RolePermissionEntity> rolePermissions) { try { int count = 0; _unitOfWork.BeginTran(); var deleteRes = await BaseDal.Delete(c => c.RoleId == roleId); foreach (var item in rolePermissions) { RolePermissionEntity ep = new RolePermissionEntity(); ep.RoleId = roleId; ep.PermissionId = item.PermissionId; ep.CreationTime = item.CreationTime; await _rolePermissionRepository.Add(ep); count++; } _unitOfWork.CommitTran(); return(count); } catch (Exception ex) { _unitOfWork.RollbackTran(); throw ex; } }
public virtual ActionResult Delete(string ids) { try { dal.Delete(ids); return(Success()); } catch (Exception e) { return(Error(e)); } }
/// <summary> /// 先删除依赖关系,再删除实体 /// </summary> /// <param name="child"></param> /// <param name="parent"></param> /// <returns></returns> public bool DeleteModel <TP, TC, TLink>(TC child, TP parent = null) where TP : BaseModel, new() where TLink : BaseLink, new() where TC : BaseModel, new() { var dal = new BaseDal <TC>(); var res = true; if (parent != null) { res = dal.DeleteLinkWith <TP, TC, TLink>(parent, child); } return(res && dal.Delete(child)); }
/// <summary> /// 先删除依赖关系,再删除实体 /// </summary> /// <param name="proj"></param> /// <param name="pProj"></param> /// <returns></returns> public bool DeleteModel <TParent, TLink>(T proj, TParent pProj = null) where TParent : BaseModel, new() where TLink : BaseLink, new() { var res = true; if (pProj != null) { res = Dal.DeleteLinkWith <TParent, T, TLink>(pProj, proj); } return(res && Dal.Delete(proj)); }
/// <summary> /// 删除取消关注的用户 /// </summary> /// <param name="OpenID"></param> public void Delete(string OpenID) { dal.Delete(p => p.OpenID == OpenID); }
public bool Delete(T t) { return(baseDal.Delete(t) > 0 ? true : false); }
public bool Delete(T entity) { CurrentDal.Delete(entity); return(DbSession.SaveChanges() > 0); }
/// <summary> /// 删除实体by ID /// </summary> /// <param name="id"></param> /// <returns></returns> public int Delete(object id) { return(dal.Delete(id)); }
/// <summary> /// 应用与非连接的对象 /// </summary> /// <param name="t"></param> /// <returns></returns> public bool Delete(T t) { dal.Delete(t); return(dal.SaveChanges() > 0); }