/// <summary> /// 新建实体时使用 /// </summary> //todo:需要检查成员初始化的类型是否正确 public static VoteOption New() { VoteOption voteOption = new VoteOption() { FeaturedImage = string.Empty, LinkPath = string.Empty, OptionName = string.Empty }; return(voteOption); }
/// <summary> /// 投票 /// </summary> /// <param name="voteId">投票Id</param> /// <param name="voteOptionId">投票选项Id</param> /// <param name="userId">投票人</param> /// <param name="isAnoymity">是否匿名</param> /// <returns>投票是否成功</returns> public bool VoteVoteOption(long voteId, long voteOptionId, long userId, bool isAnoymity) { //投票选项 VoteOption voteOption = voteOptionRepository.Get(voteOptionId); voteOption.VoteCount = voteOption.VoteCount + 1; voteOptionRepository.Update(voteOption); //投票记录 VoteRecord voteRecord = new VoteRecord() { VoteId = voteId, OptionId = voteOptionId, UserId = userId, DateCreated = DateTime.Now, IsAnoymity = isAnoymity, IP = "" }; return(Convert.ToInt32(voteRecordRepository.Insert(voteRecord)) > 0 ? true:false); }
/// <summary> /// 创建投票选项 /// </summary> /// <param name="voteOptions">投票选项</param> public void CreateVoteOption(VoteOption voteOption) { voteOptionRepository.Insert(voteOption); }