Ejemplo n.º 1
0
        public IActionResult ForumComments(MComment new_comment, int MessageId)
        {
            if (ModelState.IsValid)
            {
                int?userIndb = HttpContext.Session.GetInt32("UserId");

                dbContext.MComments.Add(new_comment);
                new_comment.UserId    = (int)userIndb;
                new_comment.MessageId = MessageId;
                dbContext.SaveChanges();
                return(Redirect("/forum"));
            }
            else
            {
                ViewBag.AllMessages = dbContext.Messages
                                      .Include(fd => fd.MessageCreator)
                                      .Include(ds => ds.PostedComments)
                                      .ThenInclude(u => u.MUser)
                                      .OrderByDescending(f => f.MessageId)
                                      .ToList();
                int?userIndb = HttpContext.Session.GetInt32("UserId");
                ViewBag.User = dbContext.Users.Include(u => u.MyActions).ThenInclude(b => b.NavMovie).ThenInclude(m => m.Comments).ThenInclude(c => c.NavCUser).FirstOrDefault(u => u.UserId == userIndb);

                return(View("Forum"));
            }
        }
Ejemplo n.º 2
0
        public IActionResult Delete_Comment(int MCommentId)
        {
            MComment ToBeDeleted = dbContext.MComments.FirstOrDefault(c => c.MCommentId == MCommentId);

            dbContext.MComments.Remove(ToBeDeleted);
            dbContext.SaveChanges();
            return(RedirectToAction("Forum"));
        }
Ejemplo n.º 3
0
        public async Task Delete(MComment c)
        {
            var ID = c.CommentID;

            if (c.UserID == SignedInUser.User.UserID)
            {
                await commentService.Remove(ID);
                await InitComment();
            }
        }