Exemple #1
0
        public static async Task <ReturnResult> Delete(this Post post, string userId, IPhoto photoUploads,
                                                       IPhotoAccessor photoAccessor, IYoutube youtubeuploader, IVideo videoContext, IPost postContext)
        {
            var keys = await postContext.GetKeys(post.Id);

            var videoResult = await youtubeuploader.DeleteVideo(keys[0].VideoId);

            var imageResult = photoAccessor.DeletePhoto(keys[0].PhotoId);

            if (videoResult && imageResult.ToLower().Equals("ok"))
            {
                await postContext.Delete(post);
            }

            if (await postContext.SaveChanges())
            {
                return new ReturnResult
                       {
                           Succeeded = true
                       }
            }
            ;


            return(new ReturnResult
            {
                Succeeded = false,
                Error = "error deleting value from database"
            });
        }
        public IActionResult DeleteConfirmed(int id)
        {
            var redirect = _post.GetById(id).Forum.Id;

            _post.Delete(id);
            return(RedirectToAction("Details", "Forum", new { id = redirect }));
        }
        public IActionResult ConfirmDelete(int id)
        {
            var post = _postService.GetById(id);

            _postService.Delete(id);

            return(RedirectToAction("Index", "Forum", new { id = post.Forum.Id }));
        }
        public async Task <IActionResult> Delete(int id)
        {
            var post = _postService.GetById(id);

            await _postService.Delete(id);

            return(RedirectToAction("Index", "Forum"));
        }
        public async Task <IActionResult> Remove(int id)
        {
            var post  = _postService.GetById(id);
            var forum = _forumService.GetById(post.Forum.Id);
            await _postService.Delete(id);

            return(RedirectToAction("Topic", "Forum", new { id = forum.Id }));
        }
Exemple #6
0
        public IActionResult ConfirmDelete(DeletePostModel model)
        {
            var post = _postService.GetById(model.PostId);

            _postService.Delete(model.PostId);

            return(RedirectToAction("Index", "Forum", new { id = post.Forum.Id }));
        }
Exemple #7
0
        public async Task <IActionResult> OnPostDelete()
        {
            // get post being deleted
            var post = await _post.GetPost(Post.Id);

            await _post.Delete(post);

            return(RedirectToPagePermanent("Posts"));
        }
        public async Task<IActionResult> Delete(int Id)
        {
            var section = _sectionService.GetByID(Id);

            foreach (var posts in section.Posts.ToList())
            {
                await _postService.Delete(posts.Id);
            }

            await _sectionService.Delete(Id);
            return RedirectToAction("Index", "Section");
        }
Exemple #9
0
        public async Task <IActionResult> Delete(int id)
        {
            var postToDelete = _postService.GetById(id);

            try
            {
                await _postService.Delete(id);
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                return(RedirectToAction("Delete", new { id, saveChangesError = true }));
            }

            return(RedirectToAction("PostsByTopic", "Posts", new { id = postToDelete.Topic.Id }));
        }
        public async Task <IActionResult> Delete(int id)
        {
            var postToDelete = _postService.GetById(id);

            if (postToDelete == null)
            {
                return(NotFound());
            }
            try
            {
                await _postService.Delete(id);
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                return(BadRequest("Unable to delete. Try again..."));
            }
            return(NoContent());
        }
        public async Task <IActionResult> Delete(int Id)
        {
            await _postService.Delete(Id);

            return(RedirectToAction(nameof(Index)));
        }
 public IActionResult DeletePost(Post post)
 {
     _postService.Delete(post.Id).Wait();
     return(Redirect("/Forum"));
 }
Exemple #13
0
 public void Delete(int id)
 {
     _context.Delete(id);
 }
        public async Task <IActionResult> Delete(int postId, int forumId)
        {
            await _postService.Delete(postId);

            return(RedirectToAction("Topic", "Forum", new { id = forumId }));
        }
Exemple #15
0
        public async Task <IActionResult> Delete(int id)
        {
            await _postService.Delete(id);

            return(Redirect("~/Forum/"));
        }
Exemple #16
0
 public IActionResult Delete(int id)
 {
     _post.Delete(id);
     return(View());
 }
Exemple #17
0
        /// <summary>
        /// Delete post
        /// </summary>
        /// <returns>Task IActionResult</returns>
        public async Task <IActionResult> OnPostDelete()
        {
            await _post.Delete(ID.Value);

            return(RedirectToPage("/Index"));
        }
Exemple #18
0
        public async Task <IActionResult> Delete(int Id)
        {
            await _postService.Delete(Id);

            return(RedirectToAction("Index", "Home"));
        }