Exemple #1
0
        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 }));
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public string Delete(int id, string userId)
        {
            Post postToRemove = Get(id);

            if (postToRemove == null)
            {
                throw new Exception("invalid id");
            }
            _repo.Delete(id);
            return("deleted");
        }
Exemple #4
0
        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" }));
        }
Exemple #6
0
 public IHttpActionResult Delete(int id)
 {
     postsrepository.Delete(id);
     return(StatusCode(HttpStatusCode.NoContent));
 }
Exemple #7
0
 public ActionResult Delete(Guid id)
 {
     _repository.Delete(id);
     return(RedirectToAction("Index"));
 }