public IActionResult Index(Post post)
 {
     pd.AddPost(post);
     pd.Commit();
     //ViewBag.message = "Posted Successfully";
     return(RedirectToAction("MyPost", "Post", new { Id }));
     // return View();
 }
예제 #2
0
        public ActionResult <Post> GetPostLike(int id)
        {
            var post = _postData.GetPostById(id);

            post.LikeCount++;
            _postData.Commit();


            if (post == null)
            {
                return(NotFound());
            }

            return(post);
        }
예제 #3
0
        public ActionResult <User> PostUser(User user)
        {
            _postData.AddUser(user);
            _postData.Commit();

            return(CreatedAtAction("GetUser", new { email = user.Email }, user));
        }
예제 #4
0
        public ActionResult <Comment> PostComment(Comment comment)
        {
            _postData.AddComment(comment);
            _postData.Commit();

            return(Ok("Sucessfully Added Comment"));
        }
예제 #5
0
        public IActionResult Create(PostEditViewModel post)
        {
            if (ModelState.IsValid)
            {
                var newPost = new Post();
                newPost.Title     = post.Title;
                newPost.Type      = post.Type;
                newPost.Content   = post.Content;
                newPost.Upvotes   = 1;
                newPost.Downvotes = 0;
                newPost.Poster    = _userManager.GetUserAsync(User).Result;
                newPost           = _postData.Add(newPost);
                _postData.Commit();

                return(RedirectToAction("Details", new { id = newPost.Id }));
            }
            return(View());
        }
예제 #6
0
        public IActionResult OnPost(int postId)
        {
            var post = postData.DeletePost(postId);

            postData.Commit();
            if (post == null)
            {
                return(RedirectToPage("./NotFound"));
            }
            return(RedirectToPage("./List"));
        }
예제 #7
0
 public IActionResult Index(Comment comment, int id)
 {
     pd.AddComment(comment);
     pd.Commit();
     return(RedirectToAction("MyPost", "Post", new { id }));
 }
 public IActionResult LikePost(int postId)
 {
     pd.incrementLike(postId);
     pd.Commit();
     return(RedirectToAction("AllPost", "Post"));
 }