public async Task <BeerStyleDto> AddAsync(BeerStyleDto otherDto) { var beerStyle = Mapper.Map <BeerStyleDto, BeerStyle>(otherDto); await _beerStyleRepository.AddAsync(beerStyle); var result = await _beerStyleRepository.GetSingleAsync(beerStyle.BeerStyleId, "SubStyles", "SuperStyle"); var mappedResult = Mapper.Map <BeerStyle, BeerStyleDto>(result); await _beerStyleElasticsearch.UpdateAsync(mappedResult); return(mappedResult); }
public async Task <BeerStyleDto> AddAsync(BeerStyleDto beerStyleDto) { var beerStyle = AutoMapper.Mapper.Map <BeerStyleDto, BeerStyle>(beerStyleDto); await _beerStyleRepository.AddAsync(beerStyle); var result = await _beerStyleRepository.GetSingleAsync(beerStyle.BeerStyleId); var mappedResult = AutoMapper.Mapper.Map <BeerStyle, BeerStyleDto>(result); _logger.LogInformation(mappedResult.Name); await _beerStyleElasticsearch.UpdateAsync(mappedResult); await IndexHopAsync(beerStyle); return(mappedResult); }
public async Task AddAsync_Gets_Added() { var newBeerStyle = new BeerStyle { Name = "Test BeerStyle", ABVHigh = 1, ABVLow = 5, IBUHigh = 1, IBULow = 1, SRMHigh = 5, SRMLow = 3, OGLow = 1.001, OGHigh = 1.003, FGLow = 1.004, FGHigh = 1.005, Comments = "Notes", SuperStyleId = 1 }; await _beerStyleRepository.AddAsync(newBeerStyle); var beerStyle = await _beerStyleRepository.GetSingleAsync(newBeerStyle.BeerStyleId); Assert.NotNull(beerStyle); }