Exemple #1
0
        /// <summary>
        /// 创建评分
        /// </summary>
        /// <param name="rating">评分</param>
        /// <returns>true-评分成功,false-评分失败(可能今日评分已超过限额)</returns>
        public bool Create(BarRating rating)
        {
            BarThreadService barThreadService = new BarThreadService();
            BarThread        thread           = barThreadService.Get(rating.ThreadId);

            EventBus <BarRating> .Instance().OnBefore(rating, new CommonEventArgs(EventOperationType.Instance().Create()));

            bool result = false;


            bool.TryParse(barRatingRepository.Insert(rating).ToString(), out result);

            if (result)
            {
                //给楼主加威望/交易积分
                IUserService userService = DIContainer.Resolve <IUserService>();
                userService.ChangePoints(thread.UserId, 0, rating.ReputationPoints, rating.TradePoints);
                PointService pointService = new PointService();
                pointService.CreateRecord(thread.UserId, "帖子评分", "发布的帖子被其他用户评分", 0, rating.ReputationPoints, rating.TradePoints);

                EventBus <BarRating> .Instance().OnAfter(rating, new CommonEventArgs(EventOperationType.Instance().Create()));
            }
            return(result);
        }