public void DeletePost_WhenEmptyContext_ReturnsUnsuccessfulOperation() { // Arrange var postsCount = _appDbContext.Posts.Count(); var id = 1; // Act var operationResult = _postManager.DeleteAsync(id).GetAwaiter().GetResult(); var postsCountAfterOperation = _appDbContext.Posts.Count(); // Assert Assert.Equal(0, operationResult); Assert.Equal(postsCount, postsCountAfterOperation); }
public async Task Delete(EntityDto <Guid> input) { var postId = input.Id; var post = await _postRepository.GetAsync(postId); var tags = await GetTagsOfPost(postId); await _tagManager.DecreaseUsageCountOfTagsAsync(tags.Select(t => t.Id).ToList()); await _commentManager.DeleteCommentsOfPost(postId); await _postManager.DeleteAsync(input.Id); }
public async Task Delete(DeletePostInput input) { // Determine user is the author of the post or not (var res, var post) = await IsOwner(AbpSession.UserId, input.Id); if (!res) { return; } ObjectMapper.Map(input, post); await _postManager.DeleteAsync(post); }
public async Task <IActionResult> OnPostDelete() { try { if (ID != null && ID > 0) { await _postMinion.DeleteAsync((int)ID); } return(RedirectToPage("../Index")); } catch (Exception e) { ViewData["ErrorMessage"] = e.Message; return(RedirectToPage("/", new { id = ID })); } }
public async Task DeleteAsync(Guid id) { await _postManager.DeleteAsync(id); }
/// <summary> /// Deletes post from database and redirects to Index Page /// </summary> /// <returns></returns> public async Task <IActionResult> OnPostDelete() { await _post.DeleteAsync(ID.Value); return(RedirectToPage("/Index")); }