コード例 #1
0
        public async Task AddAsync_Get_Added()
        {
            var newBrewery = new Brewery
            {
                Name        = "NewBrewery" + DateTime.Now.Ticks,
                Description = "Somehting",
                Type        = "HomeBrewery",
                OriginId    = 5,
                Address     = "Something",
                Latitude    = 60.3894,
                Longitude   = 5.33,
                Website     = "Something",
                HeaderImage = "Something",
                Avatar      = "Something",
            };
            await _breweryRepository.AddAsync(newBrewery);

            var breweries = await _breweryRepository.GetAllAsync(0, 20);

            Assert.True(breweries.Any(b => b.Name == newBrewery.Name));
        }
コード例 #2
0
        public async Task <BreweryDto> AddAsync(BreweryDto breweryDto)
        {
            var brewery = Mapper.Map <BreweryDto, Brewery>(breweryDto);
            await _breweryRepository.AddAsync(brewery);

            var result = await _breweryRepository.GetSingleAsync(brewery.BreweryId, "Members.Member", "Origin", "Beers", "Socials", "Beers.Beer.IBU", "Beers.Beer.ABV", "Beers.Beer.SRM", "Beers.Beer.BeerStyle");

            var mappedResult = Mapper.Map <Brewery, BreweryDto>(result);
            await _breweryElasticsearch.UpdateAsync(mappedResult);

            return(mappedResult);
        }
コード例 #3
0
        public async Task <BreweryDto> AddAsync(BreweryDto breweryDto)
        {
            var brewery = AutoMapper.Mapper.Map <BreweryDto, Brewery>(breweryDto);
            await _breweryRepository.AddAsync(brewery);

            var result = await _breweryRepository.GetSingleAsync(brewery.BreweryId);

            var mappedResult = AutoMapper.Mapper.Map <Brewery, BreweryDto>(result);
            await _breweryElasticsearch.UpdateAsync(mappedResult);

            return(mappedResult);
        }