コード例 #1
0
ファイル: BlogController.cs プロジェクト: oskarfigura/Blog
        public async Task <IActionResult> Delete(string postId)
        {
            var deleteResult = await _postRepo.DeletePost(postId);

            return(RedirectToAction("Index", "PostManager",
                                    new { PostDeleted = deleteResult }));
        }
コード例 #2
0
 public ActionResult DeletePost(Guid id)
 {
     if (_postRepo.DeletePost(id))
     {
         return(Ok("Post was deleted"));
     }
     return(BadRequest("Some problem occured during deletion the post"));
 }
コード例 #3
0
ファイル: PostController.cs プロジェクト: WAD00007717/CW
        public async Task <ActionResult> DeletePost(int id)
        {
            var postModelFromRepo = await _repository.GetPostByIdAsync(id);

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

            _repository.DeletePost(postModelFromRepo);
            await _repository.SaveChangesAsync();

            return(NoContent());
        }
コード例 #4
0
 public async Task<IActionResult> DeletePost(int id){
     try
     {
         await _repo.DeletePost(id);
         if(await _repo.SaveChangesAsync()){
             return Ok("Postagem deletada");
         }
         return BadRequest("Não foi possível adicionar a postagem");
     }
     catch (System.Exception)
     {
         
         return BadRequest("Não foi possível adicionar a postagem");
     }
 }
コード例 #5
0
 public async void DeletePost(string content)
 {
     int userId = Int32.Parse(content);
     await _postRepo.DeletePost(userId);
 }