public bool Delete(List <string> ids) { foreach (var id in ids) { CurrentDal.Delete(id); } return(DbSession.SaveChanges() > 0); }
/// <summary> /// 批量删除 /// </summary> /// <param name="ids">多个id</param> /// <returns>true</returns> public int DeleteList(List <int> ids) { foreach (var id in ids) { CurrentDal.Delete(id); } return(DbSession.SaveChanges()); }
public bool Delete(int id) { try { CurrentDal.Delete(id); return(DbSession.SaveChanges() > 0); } catch (Exception e) { return(false); } }
public bool DeleteRes(List <int> idlist) { foreach (int id in idlist) { Reservation entity = GetEntities(u => u.ID == id).First(); if (entity.Status == (int)StatusEnum.Normal) { CurrentDal.Delete(entity); } } return(DbSession.SaveChanges() > 0); }
public bool Delete(T entity) { CurrentDal.Delete(entity); return(DbSession.SaveChanges() > 0); }
public bool Delete(int id) { CurrentDal.Delete(id); return(DbSession.SaveChanges() > 0); }
/// <summary> /// 删除问卷 /// </summary> /// <param name="qid">问卷Id</param> /// <param name="message">处理后的结果信息</param> /// <returns></returns> public QssResult QssDeleteQues(int qid, out string message) { var question = CurrentDal.GetEntity(qid); if (question == null) { message = "没有该问卷"; QssLogHelper.Log("没有该问卷", $"删除问卷 {qid} 时,找不到该问卷", QssLogType.Error); return(QssResult.Fail); } // 获取当前用户 var rel = DbSession.UserDal.QssGetUserByAccount(User.Identity.Name, out User user); if (user == null) { message = "获取当前用户失败!"; QssLogHelper.Log("获取用户失败", $"删除问卷 {qid} 时,没有获取到当前用户。", QssLogType.Error); return(QssResult.Fail); } // 校验权限 if (question.Creator.Id != user.Id) { message = "没有权限!"; QssLogHelper.Log("权限不够", $"删除问卷 {qid} 时,没有获取到当前用户。", QssLogType.Error); return(QssResult.Fail); } // 删除题目和题目选项 foreach (var subject in question.QuesSubjects) { // 删除题目选项 if (subject.Type != QssQuesSubType.Subjective) { DbSession.QuesOptionDal.DeleteRange(subject.QuesOptions); QssResult result = QssSaveDeleteQues("问卷题目选项", out message); if (result != QssResult.Success) { return(result); } } } // 删除题目 DbSession.QuesSubjectDal.DeleteRange(question.QuesSubjects); QssResult _result = QssSaveDeleteQues("问卷题目", out message); if (_result != QssResult.Success) { return(_result); } // 删除问卷相关的记录 DbSession.WtLogDal.DeleteRange(DbSession.WtLogDal.GetEntities(p => p.Type == QssWtLogType.Question && p.QuesVoteId == question.Id)); _result = QssSaveDeleteQues("问卷填写记录", out message); if (_result != QssResult.Success) { return(_result); } // 删除问卷 CurrentDal.Delete(question); _result = QssSaveDeleteQues("问卷", out message); if (_result != QssResult.Success) { return(_result); } // 调整次数 user.AddQuesNum = user.AddQuesNum > 0 ? user.AddQuesNum - 1 : 0; DbSession.UserDal.Update(user); _result = QssSaveDeleteQues("问卷填写次数", out message); if (_result != QssResult.Success) { return(_result); } message = "删除问卷成功!"; return(QssResult.Success); }
public bool Delete(T t) { CurrentDal.Delete(t); return(DbSession.Savechanges() > 0); }
public int Delete(List <int> ids) { CurrentDal.Delete(ids); return(DbSession.SaveChanges()); }
public virtual bool Delete(string id) { CurrentDal.Delete(id); return(DbSession.SaveChanges() > 0); }
/// <summary> /// 按主键删除实体 /// </summary> /// <param name="keyValues">要删除实体的主键</param> /// <returns></returns> public int Delete(params object[] keyValues) { CurrentDal.Delete(keyValues); return(DbSession.SaveChanges()); }
public bool Delete(T entity) { CurrentDal.Delete(entity); DbSession.SaveChanges <DataModelContainer>(); return(true); }
/// <summary> /// 删除投票 /// </summary> /// <param name="vid">投票Id</param> /// <param name="message">处理后的结果信息</param> /// <returns></returns> public QssResult QssDeleteVote(int vid, out string message) { var vote = CurrentDal.GetEntity(vid); if (vote == null) { message = "没有该投票"; QssLogHelper.Log("没有该投票", $"删除投票 {vid} 时,找不到该投票", QssLogType.Error); return(QssResult.Fail); } // 获取当前用户 var rel = DbSession.UserDal.QssGetUserByAccount(User.Identity.Name, out User user); if (user == null) { message = "获取当前用户失败!"; QssLogHelper.Log("获取用户失败", $"删除投票 {vid} 时,没有获取到当前用户。", QssLogType.Error); return(QssResult.Fail); } // 校验权限 if (vote.Creator.Id != user.Id) { message = "没有权限!"; QssLogHelper.Log("权限不够", $"删除投票 {vid} 时,没有获取到当前用户。", QssLogType.Error); return(QssResult.Fail); } // 删除选项 DbSession.VoteOptionDal.DeleteRange(vote.VoteOptions); QssResult _result = QssSaveDeleteVote("题目", out message); if (_result != QssResult.Success) { return(_result); } // 删除投票相关的记录 DbSession.WtLogDal.DeleteRange(DbSession.WtLogDal.GetEntities(p => p.Type == QssWtLogType.Vote && p.QuesVoteId == vote.Id)); QssResult __result = QssSaveDeleteVote("投票填写记录", out message); if (__result != QssResult.Success) { return(__result); } // 删除投票 CurrentDal.Delete(vote); __result = QssSaveDeleteVote("投票", out message); if (__result != QssResult.Success) { return(__result); } // 调整次数 user.AddVoteNum = user.AddVoteNum > 0 ? user.AddVoteNum - 1 : 0; DbSession.UserDal.Update(user); __result = QssSaveDeleteVote("投票填写次数", out message); if (__result != QssResult.Success) { return(__result); } message = "删除投票成功!"; return(QssResult.Success); }