private TodoComment ConvertToDomainModel(DeleteCommentInput inputTo) { var mapper = CreateAutoMapper(); var domainModel = mapper.Map <TodoComment>(inputTo); return(domainModel); }
private DeleteCommentInput CreateInput(Guid id) { var inputTo = new DeleteCommentInput { Id = id }; return(inputTo); }
public async Task <IActionResult> DeleteComment([FromRoute] int id) { var request = new DeleteCommentInput { CommentId = id }; return(await _dispatcher.DispatchAsync(request)); }
public void DeleteComment(String contentKey, String commentListKey, int commentId) { try { CommentApi commentApi = new CommentApi(session.GetApiClient()); DeleteCommentInput deleteCommentInput = new DeleteCommentInput(contentKey, commentListKey, commentId); DeleteCommentResult deleteCommentResult = commentApi.DeleteComment(deleteCommentInput); if (deleteCommentResult.Hdr.Rc != 0) { throw new Exception("Error deleting comment. Rc=" + deleteCommentResult.Hdr.Rc); } } catch (Exception ex) { throw new Exception("Error deleting comment", ex); } }
public void Execute(DeleteCommentInput inputTo, IRespondWithResultFreeSuccessOrError <ErrorOutputMessage> presenter) { var domainModel = ConvertToDomainModel(inputTo); if (InvalidCommentId(domainModel)) { RespondWithError("Invalid comment Id", presenter); return; } if (CouldNotDelete(domainModel)) { RespondWithError("Could not locate item Id", presenter); return; } presenter.Respond(); }
public void Execute_WhenInvalidTodoItemId_ShouldReturnError() { //---------------Arrange------------------- var testContext = new DeleteCommentUseCaseTestDataBuilder() .WithDeleteResult(true) .Build(); var usecase = testContext.UseCase; var input = new DeleteCommentInput { Id = Guid.Empty }; var presenter = CreatePropertyPresenter(); //---------------Act---------------------- usecase.Execute(input, presenter); //---------------Assert----------------------- Assert.IsTrue(presenter.ErrorContent.HasErrors); Assert.AreEqual("Invalid comment Id", presenter.ErrorContent.Errors[0]); }
public void Execute_WhenTodoItemIdNotFound_ShouldReturnError() { //---------------Arrange------------------- var testContext = new DeleteCommentUseCaseTestDataBuilder() .WithDeleteResult(false) .Build(); var usecase = testContext.UseCase; var id = Guid.NewGuid(); var input = new DeleteCommentInput { Id = id }; var presenter = CreatePropertyPresenter(); //---------------Act---------------------- usecase.Execute(input, presenter); //---------------Assert----------------------- Assert.IsTrue(presenter.ErrorContent.HasErrors); Assert.AreEqual("Could not locate item Id", presenter.ErrorContent.Errors[0]); }
public void Execute_WhenValidTodoItemId_ShouldReturnSuccess() { //---------------Arrange------------------- var id = Guid.NewGuid(); var testContext = new DeleteCommentUseCaseTestDataBuilder() .WithDeleteResult(true) .Build(); var usecase = testContext.UseCase; var input = new DeleteCommentInput { Id = id }; var presenter = CreatePropertyPresenter(); //---------------Act---------------------- usecase.Execute(input, presenter); //---------------Assert----------------------- Assert.IsFalse(presenter.IsErrorResponse()); testContext.Repository.Received(1).MarkForDelete(Arg.Is <Guid>(x => x == id)); testContext.Repository.Received(1).Persist(); }
public void Delete(DeleteCommentInput input) { _commentManager.Delete(input.Id); }