// POST /api/pizza public string Post(PizzaDto pizzaDto) { var pizzaIncluir = new Pizza(); pizzaIncluir.Name = pizzaDto.Name; pizzaIncluir.Ingredients = new List<Ingredient>(); _pizzaServico.Save(pizzaIncluir); if (pizzaDto.Ingredients != null) { foreach (var ingredienteDto in pizzaDto.Ingredients) { var ingrediente = _ingredienteServico.GetById(ingredienteDto.Id); pizzaIncluir.AddIngredient(ingrediente); } } _pizzaServico.Save(pizzaIncluir); return "Pizza [" + pizzaIncluir.Id + "] incluída com sucesso!"; }
private void InsertStubData() { // Insere cada um dos ingredientes var cebola = new Ingredient { Name = "Cebola" }; _ingredientService.Save(cebola); var muçarela = new Ingredient { Name = "Muçarela" }; _ingredientService.Save(muçarela); var molhoDeTomate = new Ingredient { Name = "Molho de Tomate" }; _ingredientService.Save(molhoDeTomate); var ovo = new Ingredient { Name = "Ovo" }; _ingredientService.Save(ovo); var calabreza = new Ingredient { Name = "Calabresa" }; _ingredientService.Save(calabreza); var pizza = new Pizza { Name = "Portuguesa" }; pizza.AddIngredient(molhoDeTomate); pizza.AddIngredient(cebola); pizza.AddIngredient(ovo); _pizzaService.Save(pizza); pizza = new Pizza { Name = "Calabresa" }; pizza.AddIngredient(molhoDeTomate); pizza.AddIngredient(cebola); pizza.AddIngredient(calabreza); _pizzaService.Save(pizza); pizza = new Pizza { Name = "Muçarela" }; pizza.AddIngredient(molhoDeTomate); pizza.AddIngredient(muçarela); _pizzaService.Save(pizza); pizza = new Pizza { Name = "Pizza de vento" }; _pizzaService.Save(pizza); }
public void Save(Pizza pizza) { _pizzaDAO.Save(pizza); }