コード例 #1
0
        public static CheeseDTO MapToDTO(CheeseDAO cheese)
        {
            var c = new CheeseDTO();

            c.Id     = cheese.Id;
            c.Name   = cheese.Name;
            c.Active = cheese.Active;

            return(c);
        }
コード例 #2
0
        public RedirectToRouteResult Order(PizzaSiteModel model)
        {
            pizzaSiteModel = TempData["model"] as PizzaSiteModel;

            var pizza = new PizzaDTO();

            pizza.Sauce    = getSaucesAsync().Result.Where(m => m.Name == model.sauceString).FirstOrDefault();
            pizza.Size     = getSizesAsync().Result.Where(m => m.Name == model.sizeString).FirstOrDefault();
            pizza.Crust    = getCrustAsync().Result.Where(m => m.Name == model.crustString).FirstOrDefault();
            pizza.cheeses  = new List <CheeseDTO>();
            pizza.toppings = new List <ToppingDTO>();
            for (int x = 0; x < model.CheeseOptions.Count(); x++)
            {
                if (model.CheeseOptions[x].chosen)
                {
                    var option = new CheeseDTO();
                    option.chosen = true;
                    option.Name   = pizzaSiteModel.CheeseOptions[x].Name;
                    option.Value  = pizzaSiteModel.CheeseOptions[x].Value;
                    pizza.cheeses.Add(option);
                }
            }
            for (int x = 0; x < model.ToppingOptions.Count(); x++)
            {
                if (model.ToppingOptions[x].chosen)
                {
                    var option = new ToppingDTO();
                    option.chosen = true;
                    option.Name   = pizzaSiteModel.ToppingOptions[x].Name;
                    option.Value  = pizzaSiteModel.ToppingOptions[x].Value;
                    pizza.toppings.Add(option);
                }
            }
            pizza.Name = string.Format("{0}_{1}", pizzaSiteModel.currentCustomer.Name.ToString(), new Guid());
            model.currentOrder.currentPizza = pizza;



            pizzaSiteModel.currentOrder.Pizzas.Add(model.currentOrder.currentPizza);
            pizzaSiteModel.currentOrder.Value    = pizzaSiteModel.currentOrder.calculateValue();
            pizzaSiteModel.currentOrder.Customer = pizzaSiteModel.currentCustomer;
            pizzaSiteModel.currentOrder.Store    = pizzaSiteModel.currentStore;
            TempData["model"] = pizzaSiteModel;

            return(RedirectToAction("revieworder"));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public bool InsertCheese(CheeseDTO item)
 {
     return(pssc.InsertCheese(CheeseMapper.MapToDAO(item)));
 }
コード例 #5
0
 public bool DeleteCheese(CheeseDTO item)
 {
     return(pssc.DeleteCheese(CheeseMapper.MapToDAO(item)));
 }
コード例 #6
0
 public bool ChangeCheese(CheeseDTO item)
 {
     return(pssc.ChangeCheese(CheeseMapper.MapToDAO(item)));
 }
コード例 #7
0
        public RedirectToRouteResult AddToOrder(OrderDTO order, string returnUrl, int size, int crust, int sauce, int cheese, int[] cheeses, int[] meats, int[] veggies, string quantity)
        {
            if (size != 0 && crust != 0 && sauce != 0 && cheese != 0 && quantity != null)
            {
                SizeDTO             Size    = data.GetSize(size);
                CrustDTO            Crust   = data.GetCrust(crust);
                SauceDTO            Sauce   = data.GetSauce(sauce);
                CheeseDTO           Cheese  = data.GetCheese(cheese);
                List <CheeseDTO>    Cheeses = new List <CheeseDTO>();;
                List <MeatDTO>      Meats   = new List <MeatDTO>();
                List <VegetableDTO> Veggies = new List <VegetableDTO>();
                int Quantity = int.Parse(quantity);

                if (cheeses != null)
                {
                    for (int i = 0; i < cheeses.Length; i++)
                    {
                        Cheeses.Add(data.GetCheese(cheeses[i]));
                    }
                }
                else
                {
                    Cheeses = null;
                }

                if (meats != null)
                {
                    for (int i = 0; i < meats.Length; i++)
                    {
                        Meats.Add(data.GetMeat(meats[i]));
                    }
                }
                else
                {
                    Meats = null;
                }

                if (veggies != null)
                {
                    for (int i = 0; i < veggies.Length; i++)
                    {
                        Veggies.Add(data.GetVegetable(veggies[i]));
                    }
                }
                else
                {
                    Veggies = null;
                }

                if (data.CreatePizza(Size, Crust, Sauce, Cheese, Cheeses, Meats, Veggies, Quantity))
                {
                    PizzaDTO        pizza       = data.GetPizzas().Last();
                    OrderDetailsDTO orderDetail = new OrderDetailsDTO {
                        Pizza = pizza, Order = order
                    };
                    if (data.InsertOrderDetail(orderDetail))
                    {
                        return(RedirectToAction("Order", new { returnUrl }));
                    }
                }
            }
            return(RedirectToAction("Order", new { returnUrl }));
        }