Beispiel #1
0
        public async Task <IActionResult> CommentProductFromOrderDetailAsync([FromBody] CommentProductFromOrderDetailRequestDto requestDto)
        {
            var orderDetailBiz = new OrderDetailBiz();
            var detailModel    = await orderDetailBiz.GetModelAsync(requestDto.OrderDetailGuid);

            if (detailModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查询到此订单明细记录"));
            }
            var commentBiz = new CommentBiz();
            var comModel   = new CommentModel()
            {
                CommentGuid  = Guid.NewGuid().ToString("N"),
                TargetGuid   = requestDto.ProductGuid,
                Content      = requestDto.Content,
                Score        = requestDto.Score,
                Anonymous    = requestDto.Anonymous,
                CreatedBy    = UserID,
                CreationDate = DateTime.Now,
                Enable       = true
            };

            detailModel.CommentGuid = comModel.CommentGuid;
            var response = await commentBiz.CommentProductFromOrderDetailAsync(comModel, detailModel);

            if (response)
            {
                return(Success(comModel.CommentGuid, null));
            }
            return(Failed(ErrorCode.DataBaseError, "评论失败"));
        }
Beispiel #2
0
        public async Task <IActionResult> GetProductCommentsOfMerchantAsync([FromBody] GetProductCommentsOfMerchantRequestDto requestDto)
        {
            var commnetBiz = new CommentBiz();
            var response   = await commnetBiz.GetProductCommentsOfMerchantAsync(requestDto);

            return(Success(response));
        }
        public IActionResult EvaluateDoctorToSendIntergral(EvaluateDoctorToSendIntergralRequest request)
        {
            var commentModel = new CommentBiz().GetModel(request.CommentGuid);

            if (commentModel == null)
            {
                return(Success());//Failed(ErrorCode.DataBaseError, "评论Guid查不到信息!");
            }
            //一小时内
            TimeSpan interval          = DateTime.Now - commentModel.CreationDate;
            var      isRegisteRightNow = interval.TotalHours < 1;

            if (!isRegisteRightNow)
            {
                return(Success());//return Failed(ErrorCode.UserData, "评论时间过久,送积分失败,请联系管理员!");
            }
            //每次评价获10积分
            if (!(commentModel.Enable ? InsertIntergral(10, SendIntergralEnum.问医评价送积分, request.UserType) : false))
            {
                Logger.Error($"问医评价送积分失败!{JsonConvert.SerializeObject(request)}");
            }

            return(Success());
            // return isSucc ? Success() : Failed(ErrorCode.DataBaseError, "问医评价送积分失败!");
        }
Beispiel #4
0
 public ArticleService()
 {
     UnitOfWork = new CoreUnitOfWork();
     ArticleBiz = new ArticleBiz(UnitOfWork);
     VisitBiz   = new VisitBiz(UnitOfWork);
     CommentBiz = new CommentBiz(UnitOfWork);
     TagBiz     = new TagBiz(UnitOfWork);
 }
 public CommentService(IPushNotificationProvider pushNotificationProvider)
 {
     UnitOfWork       = new CoreUnitOfWork();
     CommentBiz       = new CommentBiz(UnitOfWork);
     NotificationBiz  = new NotificationBiz(UnitOfWork);
     ContentBiz       = new ContentBiz(UnitOfWork);
     PushNotification = pushNotificationProvider;
 }
 public DataSourceResult ReadCommentsForViewByOwner(DataSourceRequest request, UserIdentity user)
 {
     return(CommentBiz
            .Read(comment => comment.Content.AuthorId == user.UserId, noTracking: true)
            .OrderByDescending(comment => comment.CreateDate)
            .Include(comment => comment.Sender)
            .Include(comment => comment.Content)
            .MapTo <CommentInfoPM>()
            .ToDataSourceResult(request));
 }
        public void DeleteComments(IEnumerable <int> ids, UserIdentity user)
        {
            //TODO: put here a security check
            var comments = ids.Select(id => new Comment()
            {
                Id = id
            });

            comments.ForEach(comment => CommentBiz.Remove(comment));
            UnitOfWork.SaveChanges();
        }
Beispiel #8
0
 public AppStatisticsService()
 {
     UnitOfWork         = new CoreUnitOfWork();
     ArticleBiz         = new ArticleBiz(UnitOfWork);
     BlogBiz            = new BlogBiz(UnitOfWork);
     VisitBiz           = new VisitBiz(UnitOfWork);
     UserBiz            = new UserBiz(UnitOfWork);
     CommentBiz         = new CommentBiz(UnitOfWork);
     MessageBiz         = new MessageBiz(UnitOfWork);
     FeaturedContentBiz = new FeaturedContentBiz(UnitOfWork);
 }
Beispiel #9
0
        public DashboardModelContainer GetUserDashboardData(int userId)
        {
            var today = DateTime.Now.Date;

            return(new DashboardModelContainer()
            {
                PendingComments = CommentBiz.ReadNotConfirmedComments(userId).Take(4).MapTo <CommentInfoPM>().ToList(),
                ArticlesCount = ArticleBiz.ReadUserPublishedContents(userId, ContentType.Article).Count(),
                BlogPostsCount = BlogBiz.ReadUserTotalPublishedPostsCount(userId),
                TodayTotallVisits = VisitBiz.ReadUserTodayTotalVisits(userId),
                LatestMessages = MessageBiz.ReadUserMessages(userId, 4).MapTo <MessagePM>().ToList()
            });
        }
Beispiel #10
0
        public IActionResult AddComment([FromBody] AddCommentRequestDto requestDto)
        {
            var commentBiz = new CommentBiz();
            var comModel   = new CommentModel()
            {
                CommentGuid   = Guid.NewGuid().ToString("N"),
                TargetGuid    = requestDto.TargetGuid,
                Content       = requestDto.Content,
                Score         = requestDto.Score,
                Anonymous     = requestDto.Anonymous,
                CreatedBy     = UserID,
                LastUpdatedBy = UserID,
                Enable        = true
            };
            var isSuccess = commentBiz.Add(comModel);

            return(isSuccess ? Success() : Failed(ErrorCode.DataBaseError, "新增数据失败!"));
        }
Beispiel #11
0
        /// <summary>
        /// 评价医生
        /// </summary>
        /// <param name="userId">用户GUID</param>
        /// <param name="doctorGuid">医生GUID</param>
        /// <param name="score">评价分数</param>
        private void GetScoreFromAddCommentForDoctor(string userId, string doctorGuid, int score)
        {
            try
            {
                var scoreRulesBiz = new ScoreRulesBiz();
                var count         = new CommentBiz().CountUserHasCommentTargetOneDayAsync(userId, doctorGuid, DateTime.Now).Result;
                if (count > 1)
                {
                    return;
                }
                switch (score)
                {
                case 5:

                    scoreRulesBiz.AddScoreByRules(doctorGuid, Common.EnumDefine.ActionEnum.Praise5, Common.EnumDefine.UserType.Doctor);
                    break;

                case 4:
                    scoreRulesBiz.AddScoreByRules(doctorGuid, Common.EnumDefine.ActionEnum.Praise4, Common.EnumDefine.UserType.Doctor);
                    break;

                case 3:
                    scoreRulesBiz.AddScoreByRules(doctorGuid, Common.EnumDefine.ActionEnum.Praise3, Common.EnumDefine.UserType.Doctor);
                    break;

                case 2:
                    scoreRulesBiz.AddScoreByRules(doctorGuid, Common.EnumDefine.ActionEnum.Praise2, Common.EnumDefine.UserType.Doctor);
                    break;

                case 1:
                    var sd = scoreRulesBiz.AddScoreByRules(doctorGuid, Common.EnumDefine.ActionEnum.Praise1, Common.EnumDefine.UserType.Doctor);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                Common.Helper.Logger.Error($"action:{nameof(GetScoreFromAddCommentForDoctor)}  userId:{userId}  doctorGuid:{doctorGuid}  score:{score}  message:{ex.Message}");
            }
        }
Beispiel #12
0
        private void GetSonComment(GetTargetCommentResponseDto dto)
        {
            var commentBiz   = new CommentBiz();
            var userBiz      = new UserBiz();
            var accessoryBiz = new AccessoryBiz();
            var tmpModels    = commentBiz.GetModelsByTargetGuid(dto.CommentGuid);
            var lst          = new List <GetTargetCommentResponseDto>();

            foreach (var item in tmpModels)
            {
                var tmpDto         = item.ToDto <GetTargetCommentResponseDto>();
                var userModel      = userBiz.GetUser(item.CreatedBy);
                var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(userModel.PortraitGuid);
                tmpDto.NickName = userModel.NickName;
                tmpDto.Portrait = accessoryModel?.BasePath + accessoryModel?.RelativePath;
                GetSonComment(tmpDto);
                lst.Add(tmpDto);
            }
            dto.SonComments = lst;
        }
        public void AddComment(CommentRegistrationPM commentRegistrationPM, UserIdentity userIdentity)
        {
            Notification notification    = null;
            var          comment         = commentRegistrationPM.GetComment();
            var          contentAuthorId = ContentBiz.Read(c => c.Id == comment.ContentId).Select(c => c.AuthorId).Single();

            comment.SenderId = userIdentity.UserId;
            CommentBiz.AddComment(comment);
            if (userIdentity.UserId != contentAuthorId)
            {
                notification = NotificationBiz.Add(NotificationType.WriteComment, userIdentity.UserId, comment.ContentId, contentAuthorId);
            }
            UnitOfWork.SaveChanges();
            commentRegistrationPM.Id         = comment.Id;
            commentRegistrationPM.CreateDate = comment.CreateDate;
            if (notification != null)
            {
                PushNotification.Send(contentAuthorId, PushNotificationType.NewNotification, NotificationBiz.ProcessNotification(notification).GetNotificationPM());
            }
        }
Beispiel #14
0
        public IActionResult GetTargetComment([FromBody] GetTargetCommentRequestDto requestDto)
        {
            var commentBiz    = new CommentBiz();
            var userBiz       = new UserBiz();
            var accessoryBiz  = new AccessoryBiz();
            var commentModels = commentBiz.GetModels(requestDto.PageIndex, requestDto.PageSize, "where target_guid=@target_guid and enable=@enable", "last_updated_date desc", new { target_guid = requestDto.TargetGuid, enable = true });
            var theDtos       = new List <GetTargetCommentResponseDto>();
            var likeBiz       = new LikeBiz();

            foreach (var item in commentModels)
            {
                var dto            = item.ToDto <GetTargetCommentResponseDto>();
                var userModel      = userBiz.GetUser(item.CreatedBy);
                var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(userModel.PortraitGuid);
                dto.NickName   = userModel.NickName;
                dto.Portrait   = accessoryModel?.BasePath + accessoryModel?.RelativePath;
                dto.LikeNumber = likeBiz.GetLikeNumByTargetGuid(item.CommentGuid);
                GetSonComment(dto);
                theDtos.Add(dto);
            }
            return(Success(theDtos));
        }