Example #1
0
        public IActionResult Delete(PostDeleteViewModel model)
        {
            BlogModel post = _newsRepository.GetPostById(model.Id);

            _newsRepository.DeletePost(post.id);
            return(RedirectToAction("Blog"));
        }
Example #2
0
        public IActionResult Delete(PostDeleteViewModel viewModel)
        {
            var post = this.postService.GetPostById(viewModel.Id);

            this.postService.DeletePost(viewModel.Id);

            return(this.RedirectToAction("UserPosts", "User"));
        }
Example #3
0
        public async Task DeletePostAsync(PostDeleteViewModel input)
        {
            var post = this.postsRepository
                       .All()
                       .Where(x => x.Id == input.Id)
                       .FirstOrDefault();

            this.postsRepository.Delete(post);
            await this.postsRepository.SaveChangesAsync();
        }
        public async Task <IActionResult> Delete(PostDeleteViewModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            await this.postsService.DeletePostAsync(input);

            return(this.Redirect("/"));
        }
Example #5
0
        public IActionResult Delete(string id)
        {
            var post = this.postService.GetPostById(id);

            var model = new PostDeleteViewModel
            {
                Id          = post.Id,
                Title       = post.Title,
                ImageUrl    = post.FilePath,
                Description = post.Description,
                Category    = post.Category.Name,
            };

            return(this.View(model));
        }
Example #6
0
        // GET: Posts/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Post post = await db.Posts.FindAsync(id);

            if (post == null)
            {
                return(HttpNotFound());
            }
            PostDeleteViewModel postEditViewModel = ClassPostConverter.ConvertPostsToPostDeleteViewModel(post);

            return(View(post));
        }
        public static PostDeleteViewModel ConvertPostsToPostDeleteViewModel(Post post)
        {
            PostDeleteViewModel postDeleteViewModel = new PostDeleteViewModel();

            postDeleteViewModel.Id            = post.Id;
            postDeleteViewModel.SubTitle      = post.SubTitle;
            postDeleteViewModel.Title         = post.Title;
            postDeleteViewModel.PublishDate   = post.PublishDate;
            postDeleteViewModel.IsProvisional = post.IsProvisional;
            postDeleteViewModel.SlugUrl       = post.SlugUrl;
            // postDeleteViewModel.Tags = post.Tags;
            postDeleteViewModel.PostDate    = post.PostDate;
            postDeleteViewModel.Ahutor      = post.Ahutor;
            postDeleteViewModel.HtmlContent = post.HtmlContent;

            return(postDeleteViewModel);
        }