public async Task <IActionResult> Edit(int id, [Bind("CommentId,UserId,PostId,CommentDate,Content,IsDeleted")] UserCommentsOnPost userCommentsOnPost)
        {
            if (id != userCommentsOnPost.CommentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userCommentsOnPost);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserCommentsOnPostExists(userCommentsOnPost.CommentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                //return RedirectToAction(nameof(Index));
            }
            ViewData["PostId"] = new SelectList(_context.Posts, "Id", "Id", userCommentsOnPost.PostId);
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", userCommentsOnPost.UserId);
            //return View(userCommentsOnPost);
            return(RedirectToAction(actionName: "Index", controllerName: "Home"));
        }
        public async Task <IActionResult> Create([Bind("CommentId,UserId,PostId,CommentDate,Content,IsDeleted")] UserCommentsOnPost userCommentsOnPost)
        {
            if (ModelState.IsValid)
            {
                userCommentsOnPost.UserId      = _userManager.GetUserId(User);
                userCommentsOnPost.CommentDate = DateTime.Now;

                _context.Add(userCommentsOnPost);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
            }
            //ViewData["PostId"] = new SelectList(_context.Posts, "Id", "Id", userCommentsOnPost.PostId);
            //ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", userCommentsOnPost.UserId);
            return(RedirectToAction("Index", "Home"));
        }
        public JsonResult Create(string Content, int postID)
        {
            UserCommentsOnPost userCommentsOnPost = new UserCommentsOnPost();

            userCommentsOnPost.UserId      = _userManager.GetUserId(User);
            userCommentsOnPost.CommentDate = DateTime.Now;
            userCommentsOnPost.Content     = Content;
            userCommentsOnPost.PostId      = postID;
            _context.UserCommentsOnPosts.Add(userCommentsOnPost);
            _context.SaveChanges();
            //return RedirectToAction(nameof(Index));

            //ViewData["PostId"] = new SelectList(_context.Posts, "Id", "Id", userCommentsOnPost.PostId);
            //ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", userCommentsOnPost.UserId);
            return(Json(""));
        }
        public JsonResult Edit(int CommentId, string UserId, int PostId, DateTime CommentDate, string Content, bool IsDeleted)
        {
            UserCommentsOnPost userCommentsOnPost = new UserCommentsOnPost();

            userCommentsOnPost.CommentId   = CommentId;
            userCommentsOnPost.UserId      = UserId;
            userCommentsOnPost.PostId      = PostId;
            userCommentsOnPost.CommentDate = CommentDate;
            userCommentsOnPost.Content     = Content;
            userCommentsOnPost.IsDeleted   = IsDeleted;


            //if (id != userCommentsOnPost.CommentId)
            //{
            //    return NotFound();
            //}


            try
            {
                _context.Update(userCommentsOnPost);
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserCommentsOnPostExists(userCommentsOnPost.CommentId))
                {
                    return(Json("Not Found"));
                }
                else
                {
                    throw;
                }
            }

            ViewData["PostId"] = new SelectList(_context.Posts, "Id", "Id", userCommentsOnPost.PostId);
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", userCommentsOnPost.UserId);
            //return View(userCommentsOnPost);
            return(Json(""));
        }