Ejemplo n.º 1
0
        public static MeatToppingDTO MapToDTO(MeatToppingDAO topping)
        {
            var mt = new MeatToppingDTO();

            mt.Id     = topping.Id;
            mt.Pizza  = PizzaMapper.MapToDTO(topping.Pizza);
            mt.Meat   = MeatMapper.MapToDTO(topping.Meat);
            mt.Active = topping.Active;

            return(mt);
        }
        public bool CreatePizza(SizeDTO size, CrustDTO crust, SauceDTO sauce, CheeseDTO cheese, List <CheeseDTO> cheeses, List <MeatDTO> meats, List <VegetableDTO> vegetables, int quantity)
        {
            PizzaDTO pizza = new PizzaDTO {
                Size = size, Crust = crust, Sauce = sauce, Cheese = cheese, Quantity = quantity, Active = true
            };

            if (InsertPizza(pizza))
            {
                pizza = GetPizzas().Last();
                if (cheeses != null)
                {
                    foreach (var item in cheeses)
                    {
                        CheeseToppingDTO ct = new CheeseToppingDTO {
                            Cheese = item, Pizza = pizza
                        };
                        if (InsertCheeseTopping(ct))
                        {
                            continue;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                if (meats != null)
                {
                    foreach (var item in meats)
                    {
                        MeatToppingDTO mt = new MeatToppingDTO {
                            Meat = item, Pizza = pizza
                        };
                        if (InsertMeatTopping(mt))
                        {
                            continue;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                if (vegetables != null)
                {
                    foreach (var item in vegetables)
                    {
                        VegetableToppingDTO vt = new VegetableToppingDTO {
                            Vegetable = item, Pizza = pizza
                        };
                        if (InsertVegetableTopping(vt))
                        {
                            continue;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
 public bool DeleteMeatTopping(MeatToppingDTO item)
 {
     return(pssc.DeleteMeatTopping(MeatToppingMapper.MapToDAO(item)));
 }
 public bool InsertMeatTopping(MeatToppingDTO item)
 {
     return(pssc.InsertMeatTopping(MeatToppingMapper.MapToDAO(item)));
 }
 public bool ChangeMeatTopping(MeatToppingDTO item)
 {
     return(pssc.ChangeMeatTopping(MeatToppingMapper.MapToDAO(item)));
 }