Beispiel #1
0
        public GeneralResponse Delete(BlogPost item)
        {
            _repository.Delete(item);
            item.IsDeleted = true;

            return(new GeneralResponse());
        }
        public ActionResult Delete(string userName)
        {
            var user = Logic.Find(u => u.UserName == userName);
            IEnumerable <BlogPost>    blogPosts = BlogRepo.Get(o => o.UserId == user.Id, null, "", 0, 0);
            IEnumerable <PostComment> comments  = CommentRepo.Get(o => o.UserId == user.Id, null, "", 0, 0);

            foreach (var item in blogPosts)
            {
                IEnumerable <PostComment> commentsFor = CommentRepo.Get(o => o.BlogpostId == item.Id, null, "", 0, 0);
                foreach (var comment in commentsFor)
                {
                    CommentRepo.Delete(comment.Id);
                }
                BlogRepo.Delete(item.Id);
            }

            foreach (var item in comments)
            {
                CommentRepo.Delete(item.Id);
            }

            CommentRepo.Commit();
            Logic.Delete(user);
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public Result DeletePost(Guid id)
        {
            var post = _blogPostRepository.Get(id);

            _blogPostRepository.Delete(post);

            return(Result.AsSuccess());
        }
Beispiel #4
0
        public void DeleteBlogPost(string userId, string _id)
        {
            var post = _blogPostRepository.GetByUserIdAndId(userId, _id);

            if (post == null)
            {
                throw new NotFoundException("Post não encontrado");
            }
            _blogPostRepository.Delete(_id);
        }
        public Result <bool> Delete([FromUri] string token, [FromUri] int id)
        {
            var user =
                _tokenValidator.ValidateToken(token);

            if (user == null)
            {
                return(Result <bool> .Unauthorized);
            }

            return(_blogPostRepository.Delete(id));
        }
Beispiel #6
0
 public IActionResult DeleteBlog([FromRoute] string slug)
 {
     try
     {
         _repositoryBlogPost.Delete(slug);
         return(NoContent());
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message, ex);
         return(StatusCode(500));
     }
 }
Beispiel #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            BlogPost blogPost = Repo.GetById(id);
            IEnumerable <PostComment> comments = CommentRepo.Get(o => o.BlogpostId == id, null, "", 0, 0);

            foreach (var item in comments)
            {
                CommentRepo.Delete(item.Id);
            }
            Repo.Delete(blogPost);
            Repo.Commit();
            return(RedirectToAction("Index"));
        }
Beispiel #8
0
        public IHttpActionResult Delete(int id)
        {
            var postInDb = _blogPostRepository.GetById(id);

            if (postInDb == null)
            {
                return(NotFound());
            }

            _blogPostRepository.Delete(id);

            return(Ok());
        }
        public DeleteBlogPostResponse DeleteBlogPost(DeleteBlogPostRequest request)
        {
            var response = new DeleteBlogPostResponse();
            var postId   = request.PostId;

            try
            {
                var post = _blogPostRepo.GetById(postId);
                _blogPostRepo.Delete(post);
                response.DeleteSuccessful = true;
            }
            catch (Exception)
            {
                response.DeleteSuccessful = false;
            }
            return(response);
        }
Beispiel #10
0
        public async Task <IActionResult> Delete(int blogId, int id)
        {
            BlogPost bp = bprepository.GetBlogPost(id);
            Blog     b  = brepository.get(blogId);
            //bp.Author = await userManager.FindByIdAsync(bp.AuthorId);
            var isAuthorized = await auth.AuthorizeAsync(
                User, bp.Author, UserOperations.UserRole);

            var isA = await auth.AuthorizeAsync(
                User, b.User, UserOperations.UserRole);

            if (!isAuthorized.Succeeded)
            {
                if (!isA.Succeeded)
                {
                    return(View("Ingentilgang"));
                }
                return(View("Ingentilgang"));
            }

            bprepository.Delete(bp);
            TempData["message"] = "BloggPost slettet";
            return(RedirectToAction("Index", new { @ID = blogId }));
        }
        public async Task <bool> Delete(string blogPostId)
        {
            var success = await _repository.Delete(blogPostId);

            return(success);
        }
        public void Delete(string slug)
        {
            BlogPost blogPost = _blogPostRepository.GetBlogPostBySlug(slug);

            _blogPostRepository.Delete(blogPost);
        }
 public ActionResult Delete(int id)
 {
     _blogPostRepository.Delete(id);
     return(RedirectToAction("Index", "Admin"));
 }
Beispiel #14
0
        public void DeleteBlogPost(Guid id)
        {
            var deletedBlog = blogRepository.GetById(id);

            blogRepository.Delete(deletedBlog);
        }
Beispiel #15
0
 public void Delete(BlogPost blogPost)
 {
     repo.Delete(blogPost);
     repo.Save();
 }