Exemplo n.º 1
0
        //Creates a drink object with the listed paramteters below.
        public async Task <DrinkForListDto> Create(DrinkForListDto drink)
        {
            var dr = new Drink()
            {
                ProductNameBold = drink.ProductNameBold,
                Category        = drink.Category,
                Volume          = drink.Volume,
                Price           = drink.Price,
                Taste           = drink.Taste,
                Image           = drink.Image
            };

            _context.Drinks.Add(dr);
            await _context.SaveChangesAsync();

            return(DrinkTranslator.TodrinkForListDto(dr));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([FromBody] DrinkForListDto drink)
        {
            var result = await _drinkService.Create(drink);

            return(new OkObjectResult(ApiResponse.Create(result)));
        }