public ActionResult Delete(int id) { PostsRepository repo = new PostsRepository(); Post item = repo.GetById(id); repo.Delete(item); return(RedirectToAction("Index", "Posts", new { SubRedditId = item.SubRedditId })); }
public void DeletePost(int postId, int userId) { var post = _postsRepository.FindById(postId); if (post.UserId != userId) { throw new ForbiddenException("You have no right to delete this post"); } _postsRepository.Delete(post); }
public string Delete(int id, string userId) { Post postToRemove = Get(id); if (postToRemove == null) { throw new Exception("invalid id"); } _repo.Delete(id); return("deleted"); }
public void DeletePostsService(PostsDTO entity) { var posts = postsRepository.GetAll().Where(x => x.PostId == entity.PostId).FirstOrDefault(); posts.PostCategoryId = entity.PostCategoryId; posts.PostTitle = entity.PostTitle; posts.PostDiscription = entity.PostDiscription; posts.PostPhoto = entity.PostPhoto; postsRepository.Delete(posts); }
public ActionResult Delete(int id) { var model = new PostsModel() { PostId = id, UpdateUid = User.GetClaimValue(ClaimTypes.PrimarySid), UpdateDate = DateTime.Now }; var repository = new PostsRepository(); return(Json(repository.Delete(model) ? new { result = "OK" } : new { result = "ERROR" })); }
public IHttpActionResult Delete(int id) { postsrepository.Delete(id); return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Delete(Guid id) { _repository.Delete(id); return(RedirectToAction("Index")); }