/// <summary> /// حذف اسلایدر /// </summary> /// <param name="sliderId"></param> /// <returns></returns> public async Task <IHttpActionResult> Delete(Guid sliderId) { var command = new DeleteSlideCommand { Id = sliderId }; var response = await Bus.Send <DeleteSlideCommand, DeleteSlideCommandResponse>(command); return(Ok(response)); }
public async Task <IActionResult> DeleteSlide(int slideId) { var command = new DeleteSlideCommand(slideId); var result = await _mediator.Send(command); // Here, we want DeleteSlide to be idempotent and continue to report success when deleting items // that no longer exist, since from the callers perspective, the new state they requested (for the // item to not exist any longer) is still satisfied. Therefore we only do not return Ok if we detect // an error in processing, which is represented by result being null. return(result != null?Ok() : new StatusCodeResult((int)HttpStatusCode.InternalServerError)); }
public async Task GivenInvalidIdDeleteSlideRequestHandlerReportsNoRecordChanged() { const int slideId = 1; _mockSlideWriter.DeleteSlideAsync(Arg.Is(slideId)) .Returns(false); var handler = CreateHandler(); var command = new DeleteSlideCommand(slideId); var actualResult = await handler.Handle(command, new CancellationToken()); actualResult.Should().BeNull(); }
public async Task GivenValidDeleteSlideRequestHandlerReportsSuccessfulDeletion() { const int slideId = 1; _mockSlideWriter.DeleteSlideAsync(Arg.Is(slideId)) .Returns(true); var expectedResult = new SlideResponse { Id = slideId }; var handler = CreateHandler(); var command = new DeleteSlideCommand(slideId); var actualResult = await handler.Handle(command, new CancellationToken()); actualResult.Should().BeEquivalentTo(expectedResult); }