Example #1
0
        public ActionResult DeletePost(string postId)
        {
            var rep     = new PostRepository(context);
            var idAsInt = Int32.Parse(postId);
            var deleted = rep.DeletePost(idAsInt);

            return(RedirectToAction("Profile", new { username = User.Identity.Name }));
        }
Example #2
0
        public ActionResult DeletePost(int id)
        {
            var post = _postRepository.GetPost(id);

            _postRepository.DeletePost(post);
            _postRepository.DeleteCommentsForPost(post);
            return(RedirectToAction("ViewPosts"));
        }
Example #3
0
 public bool DeletePost(Guid id)
 {
     if (_postRepository.DeletePost(id) > 0)
     {
         return(true);
     }
     return(false);
 }
Example #4
0
        public string DeletePost(int id)
        {
            bool delete = _db.DeletePost(id);

            if (delete)
            {
                return("Successfully Deleted!");
            }
            return("An Error Occurred, try again!");
        }
 public IActionResult Delete(int id, Post post)
 {
     try
     {
         _postRepository.DeletePost(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(post));
     }
 }
Example #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Post post = _postRepository.GetPostById(id);

            if (WebSecurity.CurrentUserId > 0)
            {
                if (_postRepository.DeletePost(post))
                {
                    return(RedirectToAction("MyPosts"));
                }
                return(View(post));
            }
            return(RedirectToAction("Login", "Account"));
        }
Example #7
0
        public IActionResult Delete(int id, Post post)
        {
            try
            {
                _postRepository.DeletePost(id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                // If something goes wrong, just keep the user on the same page so they can try again
                return(View(post));
            }
        }
        public HttpResponseMessage Delete(int postId)
        {
            try
            {
                var PostRepository = new PostRepository(context);

                PostRepository.DeletePost(postId);

                return Request.CreateResponse(HttpStatusCode.OK, "Post excluĂ­do com sucesso.");
            }
            catch (Exception e)
            {
                return Request.CreateResponse(HttpStatusCode.Forbidden, "Erro " + e.Message);
            }
        }
Example #9
0
        static void DeletePost(Thread thread)
        {
            var  postsByUser = GetPostByCurrentUser(thread);
            bool isEmpty     = !postsByUser.Any();

            if (!isEmpty)
            {
                int index = 1;
                foreach (var post in postsByUser)
                {
                    Console.WriteLine($"Post number:{index}");
                    Console.WriteLine($"Created by: {post.createdBy}");
                    Console.WriteLine(post.post_text);
                    Console.WriteLine("---------------------------------");
                    index++;
                }
                var tmpPost = new Post();
                Console.WriteLine("These are your posts in this thread. Write the number of the post you want to delete.");
                bool isOkay = int.TryParse(Console.ReadLine(), out int input);
                while (!isOkay || !Helper.VerifyIntBetween(1, postsByUser.Count, input))
                {
                    Console.WriteLine("You can only enter numbers that exists infront of threads. Try again.");
                    Console.WriteLine("Write the post number of the post you want to delete:");
                    isOkay = int.TryParse(Console.ReadLine(), out input);
                }
                index = 1;
                foreach (var post in postsByUser)
                {
                    if (index == input)
                    {
                        tmpPost = post;
                    }
                    index++;
                }
                PostRepository.DeletePost(tmpPost);
                Console.WriteLine("Post deleted.");
            }
            else
            {
                Console.WriteLine("You don't have any posts in this thread.");
            }
            Helper.PressAnyKeyToContinue();
        }
Example #10
0
        public ActionResult Delete(int?id)
        {
            string message = "";
            string status  = "";

            if (id != null)
            {
                var isDelete = postRepository.DeletePost(id.Value);
                if (isDelete)
                {
                    message = "post successfully deleted";
                    status  = "success";
                }
                else
                {
                    message = "error deleting post";
                    status  = "danger";
                }
            }
            TempData["message"] = message;
            TempData["status"]  = status;
            return(RedirectToAction("Index", "Post"));
        }
Example #11
0
 public int DeletePost(Guid id)
 {
     return(_postRepository.DeletePost(id));
 }
Example #12
0
 public IActionResult Delete(int postId)
 {
     return(Ok(_postRepository.DeletePost(postId)));
 }
Example #13
0
 public void DeletePost(int id) => _postRepository.DeletePost(id);
Example #14
0
 public void Delete(int id)
 {
     postRepo.DeletePost(id);
 }
Example #15
0
 public void Delete(Post post)
 {
     postRepository.DeletePost(post);
 }
 public IActionResult Delete(int id)
 {
     _context.DeletePost(id);
     return(RedirectToAction(nameof(Index)));
 }
Example #17
0
 public void DeletePost(int Id)
 {
     _postRepository.DeletePost(Id);
 }
Example #18
0
 public string DeletePost(int id)
 {
     return(_postRepository.DeletePost(id));
 }
 public PostDTO DeletePost(int id)
 {
     return(_postRepository.DeletePost(id));
 }
Example #20
0
 public void DeletePost(Post post)
 {
     _postRepo.DeletePost(post);
 }
 public IHttpActionResult Delete(int id)
 {
     pro.DeletePost(id);
     return(StatusCode(HttpStatusCode.NoContent));
 }
Example #22
0
        public bool DeletePost(int id)
        {
            var user = HttpContext.User.Identity.Name;

            return(_db.DeletePost(id, user));
        }