public async Task UpdateAsync(Guid id, Round round) { var existingRound = await _roundRepository.GetByIdAsync(id); if (existingRound == null) { AddNotification("Rodada não encontrada."); } existingRound.Update(round.Description, round.Date, round.RankingId); if (await ValidateRoundAsync(existingRound)) { _roundRepository.Update(existingRound); if (!await CommitAsync()) { AddNotification("Não foi possível atualizar a rodada."); } } }
private async Task <bool> ValidateRoundExistsAsync(Guid roundId) { var round = await _roundRepository.GetByIdAsync(roundId); if (round != null) { return(true); } AddNotification("Rodada não encontrada."); return(false); }
public async Task ReturnNullWhenRoundDoNotExistsInDbByGivenId() { // Arrange _roundRepository = SoccerStatisticsContextMocker.GetInMemoryRoundRepository("GetRoundByIdReturnNull"); Round testRound = null; // Act var err = await Record.ExceptionAsync(async () => testRound = await _roundRepository.GetByIdAsync(0)); // Assert err.Should().BeNull(); testRound.Should().BeNull(); }
public async Task ReturnRoundWhichExistsInDbByGivenId() { // Arrange _roundRepository = SoccerStatisticsContextMocker.GetInMemoryRoundRepository("GetRoundByIdReturnRound"); var expectedRound = new Round() { Id = 1, Name = "Round 1", }; Round testRound = null; // Act var err = await Record.ExceptionAsync(async () => testRound = await _roundRepository.GetByIdAsync(1)); // Assert err.Should().BeNull(); testRound.Should().NotBeNull(); testRound.Should().BeEquivalentTo(expectedRound); }
public async Task <RoundDTO> GetByIdAsync(uint id) { var round = await _roundRepository.GetByIdAsync(id); return(_mapper.Map <RoundDTO>(round)); }