/// <summary> /// 创建投票选项 /// </summary> /// <param name="voteOption">投票选项</param> /// <param name="user">当前用户</param> /// <param name="vote">当前投票</param> /// <param name="message">处理结果信息</param> /// <returns></returns> public QssResult QssCreateVoteOption(JArray options, User user, Vote vote, out string message) { List <VoteOption> entities = new List <VoteOption>(); foreach (JObject item in options) { entities.Add(new VoteOption() { Content = (string)item["Content"], Vote = vote }); } try { CurrentDal.AddRange(entities); DbSession.SaveChanges(); message = "保存投票选项成功!"; return(QssResult.Success); } catch (Exception exception) { message = "保存投票选项失败!"; QssLogHelper.Log("保存投票选项失败", $"在保存投票: {vote.Title} 时失败! 原因:{exception.Message}", QssLogType.Error, exception, $"{user.Account}({user.Name})"); throw; } }
/// <summary> /// 增加一堆实体 /// </summary> /// <param name="entities">实体集合</param> /// <returns></returns> public int AddRange(IEnumerable <T> entities) { CurrentDal.AddRange(entities); return(DbSession.SaveChanges()); }