public async Task Handle_GivenInvalidRequest_ShouldThrowNotFoundException() { // Arrange var command = new DeleteTournamentCommand { Id = 333 }; var sut = new DeleteTournamentCommandHandler(this.deletableEntityRepository); // Act & Assert await Should.ThrowAsync <NotFoundException>(sut.Handle(command, It.IsAny <CancellationToken>())); }
public ActionResult DeleteTournament(int id) { ISystemResponseMessages systemMessages = new SystemResponseMessages(ApplicationResponseMessagesEnum.NoAction, ""); var command = new DeleteTournamentCommand(id, _context); _tournamentDomainClient.PerformCommand(command, out systemMessages); if (systemMessages.MessageState().Equals(ApplicationResponseMessagesEnum.Success)) { return(new HttpStatusCodeResult(HttpStatusCode.OK)); } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Data not captured")); }
public async Task Handle_GivenValidRequest_ShouldDeleteEntity() { // Arrange var command = new DeleteTournamentCommand { Id = 2 }; var sut = new DeleteTournamentCommandHandler(this.deletableEntityRepository); // Act var id = await sut.Handle(command, It.IsAny <CancellationToken>()); // Assert id.ShouldBeGreaterThan(0); var deletedTournament = this.deletableEntityRepository.AllAsNoTrackingWithDeleted().SingleOrDefault(x => x.Id == 2); deletedTournament.IsDeleted.ShouldBe(true); }
public IActionResult Delete_tournament(DeleteTournamentCommand delete_tournament_command) { _logger.LogInformation($"delete tournament command, id: { delete_tournament_command.Id }"); using (var msgpump = new MessagePump(_es)) { var context_manager = new DeleteTournamentCommandContextManager(_es); var message_processor = new DeleteTournamentCommandProcessor(); msgpump.Register <DeleteTournamentCommand>(context_manager, message_processor); var result = msgpump.Handle(delete_tournament_command) as CommandStatus; if (result is Success) { return(Ok()); } else { return(BadRequest()); } } }
public SelectTournamentViewModel() { AllTournaments = GetTournaments(); DeleteTournamentCommand = new DeleteTournamentCommand(); }
public async Task <IActionResult> Delete(DeleteTournamentCommand command) { await this.Mediator.Send(command); return(this.RedirectToAction(nameof(Index))); }