Exemplo n.º 1
0
        /// <summary>
        /// 新建实体时使用
        /// </summary>
        //todo:需要检查成员初始化的类型是否正确
        public static VoteRecord New()
        {
            VoteRecord voteRecord = new VoteRecord()
            {
                DateCreated = DateTime.UtcNow,
                IP          = string.Empty
            };

            return(voteRecord);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 新建实体时使用
        /// </summary>
        //todo:需要检查成员初始化的类型是否正确
        public static VoteRecord New()
        {
            VoteRecord voteRecord = new VoteRecord()
            {
                DateCreated = DateTime.UtcNow,
                IP = string.Empty

            };
            return voteRecord;
        }