Пример #1
0
        public async Task <ActionResult <PizzaDto> > Post(PizzaDto pizzaDto)
        {
            var pizza = new Pizza()
            {
                Id            = pizzaDto.Id,
                Size          = pizzaDto.Size,
                Crust         = pizzaDto.Crust,
                Cheese        = pizzaDto.Cheese,
                Sauce         = pizzaDto.Sauce,
                PizzaToppings = pizzaDto.Toppings.Select(t => new PizzaTopping()
                {
                    PizzaId   = pizzaDto.Id,
                    ToppingId = t.Id
                }).ToList()
            };

            await context.AddAsync(pizza);

            await context.SaveChangesAsync();

            return(Ok());
        }