public IActionResult AddPenaltyPoints(int teamTableResultId) { var viewModel = new AddPenaltyPointsCommand { TeamTableResultId = teamTableResultId }; return(this.View(viewModel)); }
public async Task Handle_GivenInvalidRequest_ShouldThrowNotFoundException() { // Arrange var command = new AddPenaltyPointsCommand { TeamTableResultId = 1124124, PenaltyPoints = It.IsAny <int>() }; var sut = new AddPenaltyPointsCommandHandler(this.deletableEntityRepository); // Act & Assert await Should.ThrowAsync <NotFoundException>(sut.Handle(command, It.IsAny <CancellationToken>())); }
public async Task <IActionResult> AddPenaltyPoints(AddPenaltyPointsCommand command, int tournamentId) { if (!this.ModelState.IsValid) { return(this.RedirectToAction(nameof(AddPenaltyPoints), new { command.TeamTableResultId })); } await this.Mediator.Send(command); return(this.RedirectToAction("Tables", "Tournaments", new { Id = tournamentId })); }
public async Task Handle_GivenValidRequest_ShouldAddPenaltyPoints() { // Arrange var command = new AddPenaltyPointsCommand { TeamTableResultId = 1, PenaltyPoints = 5 }; var sut = new AddPenaltyPointsCommandHandler(this.deletableEntityRepository); // Act var affectedRows = await sut.Handle(command, It.IsAny <CancellationToken>()); // Assert affectedRows.ShouldBe(1); var updatedEntity = this.deletableEntityRepository.AllAsNoTracking().SingleOrDefault(x => x.Id == 1); updatedEntity.PenaltyPoints.ShouldBe(5); }