Ejemplo n.º 1
0
        public PartialViewResult ChildrenEventComment(CommentEvent childCom)
        {
            ApplicationUser user = null;
            string          id   = GetUserId();

            if (id != string.Empty && id != null)
            {
                user = context.Users.Where(a => a.Id == id).First();
            }



            CurrentCommentGameEventViewModel vm = new CurrentCommentGameEventViewModel
            {
                LoggedUser = user,
                Com        = childCom
            };

            if (vm.Com.Children != null && vm.Com.Children.Count > 1)
            {
                vm.Com.Children = vm.Com.Children.OrderBy(a => a.DateOfInsert).ToList();
            }

            return(PartialView("_ChildrenComments", vm));
        }
Ejemplo n.º 2
0
        public PartialViewResult AddChildCommentEvent(int idOfParentId, string content)
        {
            if (SpamDetector.IsContentSpam(content))
            {
                return(null);
            }

            var         parentComment = context.CommentEvents.Find(idOfParentId);
            GamingEvent gameEvent     = context.GamingEvents.Where(a => a.GamingEventId == parentComment.GamingEventId).First();

            ApplicationUser user = null;
            string          id   = User.Identity.GetUserId();

            if (id != string.Empty && id != null)
            {
                user = context.Users.Where(a => a.Id == id).First();
            }


            CommentEvent commentEvent = new CommentEvent()
            {
                Body                 = content,
                DateOfInsert         = DateTime.Now,
                GamingEventId        = gameEvent.GamingEventId,
                UserId               = User.Identity.GetUserId(),
                User                 = user,
                ParentCommentEventId = parentComment.CommentEventId,
                Parent               = parentComment
            };

            var sentimentalInt = new SentimentalInterpreter();
            var isContentHappy = sentimentalInt.IsHappy(commentEvent.Body);

            if (isContentHappy)
            {
                commentEvent.IsHappy = true;
            }

            parentComment.Children.Add(commentEvent);
            context.CommentEvents.Add(commentEvent);

            context.SaveChanges();


            CurrentCommentGameEventViewModel vm = new CurrentCommentGameEventViewModel
            {
                LoggedUser = user,
                Com        = parentComment
            };


            if (vm.Com.Children != null && vm.Com.Children.Count > 1)
            {
                vm.Com.Children = vm.Com.Children.OrderBy(a => a.DateOfInsert).ToList();
            }
            return(PartialView("~/Views/GamingEvent/_ChildrenComments.cshtml", vm));
        }