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 })); }
public ActionResult DeletePost(int id) { var post = _postRepository.GetPost(id); _postRepository.DeletePost(post); _postRepository.DeleteCommentsForPost(post); return(RedirectToAction("ViewPosts")); }
public bool DeletePost(Guid id) { if (_postRepository.DeletePost(id) > 0) { return(true); } return(false); }
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)); } }
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")); }
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); } }
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(); }
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")); }
public int DeletePost(Guid id) { return(_postRepository.DeletePost(id)); }
public IActionResult Delete(int postId) { return(Ok(_postRepository.DeletePost(postId))); }
public void DeletePost(int id) => _postRepository.DeletePost(id);
public void Delete(int id) { postRepo.DeletePost(id); }
public void Delete(Post post) { postRepository.DeletePost(post); }
public IActionResult Delete(int id) { _context.DeletePost(id); return(RedirectToAction(nameof(Index))); }
public void DeletePost(int Id) { _postRepository.DeletePost(Id); }
public string DeletePost(int id) { return(_postRepository.DeletePost(id)); }
public PostDTO DeletePost(int id) { return(_postRepository.DeletePost(id)); }
public void DeletePost(Post post) { _postRepo.DeletePost(post); }
public IHttpActionResult Delete(int id) { pro.DeletePost(id); return(StatusCode(HttpStatusCode.NoContent)); }
public bool DeletePost(int id) { var user = HttpContext.User.Identity.Name; return(_db.DeletePost(id, user)); }