Exemplo n.º 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 }));
        }
Exemplo n.º 2
0
        public ActionResult DeletePost(int id)
        {
            var post = _postRepository.GetPost(id);

            _postRepository.DeletePost(post);
            _postRepository.DeleteCommentsForPost(post);
            return(RedirectToAction("ViewPosts"));
        }
Exemplo n.º 3
0
 public bool DeletePost(Guid id)
 {
     if (_postRepository.DeletePost(id) > 0)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 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));
     }
 }
Exemplo n.º 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"));
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 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();
        }
Exemplo n.º 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"));
        }
Exemplo n.º 11
0
 public int DeletePost(Guid id)
 {
     return(_postRepository.DeletePost(id));
 }
Exemplo n.º 12
0
 public IActionResult Delete(int postId)
 {
     return(Ok(_postRepository.DeletePost(postId)));
 }
Exemplo n.º 13
0
 public void DeletePost(int id) => _postRepository.DeletePost(id);
Exemplo n.º 14
0
 public void Delete(int id)
 {
     postRepo.DeletePost(id);
 }
Exemplo n.º 15
0
 public void Delete(Post post)
 {
     postRepository.DeletePost(post);
 }
Exemplo n.º 16
0
 public IActionResult Delete(int id)
 {
     _context.DeletePost(id);
     return(RedirectToAction(nameof(Index)));
 }
Exemplo n.º 17
0
 public void DeletePost(int Id)
 {
     _postRepository.DeletePost(Id);
 }
Exemplo n.º 18
0
 public string DeletePost(int id)
 {
     return(_postRepository.DeletePost(id));
 }
Exemplo n.º 19
0
 public PostDTO DeletePost(int id)
 {
     return(_postRepository.DeletePost(id));
 }
Exemplo n.º 20
0
 public void DeletePost(Post post)
 {
     _postRepo.DeletePost(post);
 }
 public IHttpActionResult Delete(int id)
 {
     pro.DeletePost(id);
     return(StatusCode(HttpStatusCode.NoContent));
 }
Exemplo n.º 22
0
        public bool DeletePost(int id)
        {
            var user = HttpContext.User.Identity.Name;

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