public PizzaStoreModel()
 {
     PizzaOrder              = new PizzaOrderDAO();
     PizzaOrder.Order        = new OrderDAO();
     PizzaOrder.Order.Pizzas = new List <PizzaDAO>();
     Customer = new CustomerDAO();
     History  = new List <PizzaOrderDAO>();
 }
Example #2
0
        public static PizzaOrder MapToPizzaOrder(PizzaOrderDAO pizzaOrder)
        {
            var po = new PizzaOrder();

            po.OrderID       = pizzaOrder.Id;
            po.CustomerID    = CustomerMapper.MapToCustomer(pizzaOrder.Customer).CustomerID;
            po.StoreID       = StoreMapper.MapToStore(pizzaOrder.Store).StoreID;
            po.PaymentTypeID = PaymentTypeMapper.MapToPaymentType(pizzaOrder.Payment).PaymentTypeID;
            po.Active        = pizzaOrder.Active;

            return(po);
        }
        public async Task <List <CheeseDAO> > InsertPizzaOrder(PizzaOrderDAO order)
        {
            List <CheeseDAO> cheeses = new List <CheeseDAO>();

            client             = new HttpClient();
            client.BaseAddress = new Uri(url);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage response = await client.PostAsJsonAsync(@"http://localhost/PizzaStoreAPI/API/PizzaOrder", order);

            return(cheeses);
        }
Example #4
0
        public static PizzaOrderDAO MapToPizzaOrderDAO(PizzaOrder pizzaOrder)
        {
            var po = new PizzaOrderDAO();

            po.Id       = pizzaOrder.OrderID;
            po.Customer = CustomerMapper.MapToCustomerDAO(pizzaOrder.Customer);
            po.Store    = StoreMapper.MapToStoreDAO(pizzaOrder.Store);
            po.Payment  = PaymentTypeMapper.MapToPaymentTypeDAO(pizzaOrder.PaymentType);
            po.Active   = pizzaOrder.Active;

            return(po);
        }
Example #5
0
        public static PizzaOrderDAO MapToDAO(OrderDTO order)
        {
            var po = new PizzaOrderDAO();

            po.Id       = order.Id;
            po.Customer = CustomerMapper.MapToDAO(order.Customer);
            po.Store    = StoreMapper.MapToDAO(order.Store);
            po.Payment  = PaymentTypeMapper.MapToDAO(order.Payment);
            po.Active   = order.Active;

            return(po);
        }
Example #6
0
        public static OrderDTO MapToDTO(PizzaOrderDAO order)
        {
            var o = new OrderDTO();

            o.Id       = order.Id;
            o.Customer = CustomerMapper.MapToDTO(order.Customer);
            o.Store    = StoreMapper.MapToDTO(order.Store);
            o.Payment  = PaymentTypeMapper.MapToDTO(order.Payment);
            o.Active   = order.Active;

            return(o);
        }
Example #7
0
        public PizzaOrderDAO GetPizzaOrder(int id)
        {
            PizzaOrderDAO   po           = new PizzaOrderDAO();
            PizzaOrder      temppo       = new PizzaOrder();
            List <Order>    temporder    = new List <Order>();
            List <Pizza>    temppizzas   = new List <Pizza>();
            List <PizzaDAO> temppizzaDAO = new List <PizzaDAO>();


            temppo      = data.GetPizzaOrderByID(id);
            po.ID       = temppo.PizzaOrderID;
            po.Customer = GetCustomerByID(int.Parse(temppo.CustomerID.ToString()));
            temporder   = data.GetOrderByID(po.ID);
            temppizzas  = data.GetPizzaList(temporder);

            foreach (var item in temppizzas)
            {
                var tempToppings    = data.GetToppingsOnPizza(int.Parse(item.PizzaID.ToString()));
                var tempCheeses     = data.GetCheesesOnPizza(int.Parse(item.PizzaID.ToString()));
                var tempToppingsDAO = new List <ToppingDAO>();
                var tempCheesesDAO  = new List <CheeseDAO>();

                foreach (var i in tempToppings)
                {
                    tempToppingsDAO.Add(ToppingMapper.Topping_ToppingDAO(i));
                }
                foreach (var y in tempCheeses)
                {
                    tempCheesesDAO.Add(CheeseMapper.Cheese_CheeseDAO(y));
                }


                var t = new PizzaDAO
                {
                    ID       = item.PizzaID,
                    Crust    = CrustMapper.Crust_CrustDAO(data.GetCrustOnPizza(int.Parse(item.CrustID.ToString()))),
                    Sauce    = SauceMapper.Sauce_SauceDAO(data.GetSauceOnPizza(int.Parse(item.SauceID.ToString()))),
                    Size     = SizeMapper.Size_SizeDAO(data.GetSizeOfPizza(int.Parse(item.SizeID.ToString()))),
                    Toppings = tempToppingsDAO,
                    Cheeses  = tempCheesesDAO
                };

                temppizzaDAO.Add(t);
            }
            OrderDAO order = new OrderDAO();

            order.Pizzas = temppizzaDAO;
            po.Order     = order;

            return(po);
        }
Example #8
0
        public void InsertPizzaOrder(PizzaOrderDAO po)
        {
            List <Pizza>           Pizza    = new List <Pizza>();
            List <List <Topping> > toppings = new List <List <Topping> >();
            List <List <Cheese> >  cheeses  = new List <List <Cheese> >();

            foreach (var item in po.Order.Pizzas)
            {
                Pizza.Add(PizzaMapper.PizzaDAO_Pizza(item));
                toppings.Add(PizzaMapper.PizzaDAO_Topping(item));
                cheeses.Add(PizzaMapper.PizzaDAO_Cheeses(item));
            }

            data.InsertPizzaOrder(CustomerMapper.CustomerDAO_Customer(po.Customer), Pizza, toppings, cheeses,
                                  EmailMapper.EmailDAO_Email(po.Customer.Email),
                                  NameMapper.NameDAO_Name(po.Customer.Name),
                                  NumberMapper.NumberDAO_Number(po.Customer.Number),
                                  AddressMapper.AddressDAO_Address(po.Customer.Address));
        }
 // POST: api/PizzaOrder
 public void Post(PizzaOrderDAO pizzaorder)
 {
     data.InsertPizzaOrder(pizzaorder);
 }
 public bool ChangePizzaOrder(PizzaOrderDAO order)
 {
     return(data.ChangePizzaOrder(PizzaOrderMapper.MapToPizzaOrder(order)));
 }
 public bool InsertPizzaOrder(PizzaOrderDAO order)
 {
     return(data.InsertPizzaOrder(PizzaOrderMapper.MapToPizzaOrder(order)));
 }
 public bool DeletePizzaOrder(PizzaOrderDAO order)
 {
     return(data.DeletePizzaOrder(PizzaOrderMapper.MapToPizzaOrder(order)));
 }