public void CreateOrder(string CustomerName, string storeName)
        {
            var order = new OrderModel();

            order.CustomerSubmitted = _dbContext.Customers.SingleOrDefault(x => x.Name == CustomerName);
            order.StoreSubmitted    = _dbContext.Stores.SingleOrDefault(x => x.Name == storeName);
            order.Price             = 0;

            _dbContext.Orders.Add(order);
            _dbContext.SaveChanges();
        }
示例#2
0
        public void Create(domain.Pizza pizza)
        {
            var newPizza = new Pizza();

            newPizza.Crust = pizza.Crust;
            newPizza.Size  = pizza.Size;
            var orderDate = DateTime.UtcNow;

            _db.Pizza.Add(newPizza);
            _db.SaveChanges();
        }
示例#3
0
        //Focus: How to create & persist order information?
        public void CreateOrder()
        {
            User     UserSelect     = ValidateUser();
            Location LocationSelect = SelectLocation();

            Console.WriteLine("Welcome. Let's start by creating an order.\n" +
                              "Type Add to add more pizzas. Type Finish to complete order.");
            OrderEntity order = new OrderEntity();

            string input = Console.ReadLine();

            while (input == "Add")
            {
                PizzaEntity tempPizza = new PizzaEntity();
                //Step 1: What kind of pizza to order???
                StorePizzaDefinition tempPizzaName = SelectPizzaType();

                //Step 2: Make the pizza.
                Crust          tempCrust   = SelectCrust();
                Size           tempSize    = SelectSize();
                List <Topping> tempTopping = CreateToppingList();

                //Step 3: Choose the quantity.
                Console.WriteLine("How many pizzas do you want?");
                string QuantityChoice = Console.ReadLine();

                //Step 4: Map the information into the pizza entity.
                tempPizza.Name         = tempPizzaName.Name;
                tempPizza.Price        = tempPizzaName.Price;
                tempPizza.Quantity     = Int32.Parse(QuantityChoice);
                tempPizza.PizzaCrust   = tempCrust;
                tempPizza.PizzaSize    = tempSize;
                tempPizza.PizzaTopping = tempTopping;

                //Step 5: Add the pizza entity to order.
                order.PizzaList.Add(tempPizza);

                Console.WriteLine("Would you like to make another pizza?\n" +
                                  "As a reminder, type Add to add another pizza. Type Finish to complete order.");
                string UserDecision = Console.ReadLine();
                if (UserDecision == "Finish")
                {
                    break;
                }
            }

            //Final steps: Add user/location info to order and submit order.
            order.UserInfo           = UserSelect;
            order.LocationIdentifier = LocationSelect;
            order.OrderDate          = DateTime.Today;

            _db.OrderList.Add(order);
            _db.SaveChanges();
        }
示例#4
0
 public bool CreateStore(string StoreName)
 {
     if (Login(StoreName) == null)
     {
         _db.Stores.Add(
             new StoreModel()
         {
             Name = StoreName
         }
             );
         _db.SaveChanges();
         return(true);
     }
     return(false);
 }
 public bool CreateCustomer(string CustomerName)
 {
     if (Login(CustomerName) == null)
     {
         _dbContext.Customers.Add(
             new CustomerModel()
         {
             Name = CustomerName
         }
             );
         _dbContext.SaveChanges();
         return(true);
     }
     return(false);
 }
示例#6
0
        public void SubmitOrder(ClientOrder order, ConcretePizza pizza)
        {
            _db.Pizza.Add(new Data.Entities.Pizza {
                Crust = new Crust {
                    Name = pizza.Crust.Name, Price = pizza.Crust.Price
                },
                Size = new Size {
                    Name = pizza.Size.Name, Price = pizza.Size.Price
                },
                Price = pizza.Price
            });

            _db.SaveChanges();

            order.Pizzas.Add(pizza);
            Orders.Add(order);
        }
示例#7
0
        public IActionResult Checkout(string id)
        {
            decimal total;

            total = System.Convert.ToDecimal(id);
            long userId = System.Convert.ToInt64(TempData["userid"]);

            if (TempData["userid"] == null)
            {
                return(View("OrderDetails"));
            }
            Order order = new Order();

            order.UserId   = userId;
            order.StoreId  = storeId;
            order.totPrice = total;

            foreach (var pizza in _selection)
            {
                PizzaOrder po = new PizzaOrder();
                po.Quantity = pizza.Quantity;
                po.OrderId  = order.OrderId;
                Pizza p = _pr.Get(pizza.SelectedPizza);
                po.Id = p.Id;
                order.PizzaOrders.Add(po);
            }
            _db.Orders.Add(order);
            var save = _db.SaveChanges() == 1;

            _selection.Clear();

            new PizzaController();
            foreach (var sel in _selection)
            {
                _selection.Remove(sel);
            }

            TempData["checkout"] = "Your Order was succesful";
            return(View("Checkout"));
        }
示例#8
0
        public IActionResult CreateAccount(string username, string password1, string password2)
        {
            foreach (var item in _db.Users)
            {
                if (username == item.UserName)
                {
                    return(View());
                }
            }
            if (password1 != password2)
            {
                return(View());
            }

            User u = new User();

            u.UserName = username;
            u.Password = password1;

            _db.Users.Add(u);
            _db.SaveChanges();

            return(RedirectToAction("FrontPage"));
        }
示例#9
0
 public bool Post(Store store)
 {
     _db.Stores.Add(store);
     return(_db.SaveChanges() == 1);
 }
示例#10
0
 public bool Post(Order order)
 {
     //_db.Add(po);
     _db.Orders.Add(order);
     return(_db.SaveChanges() == 1);
 }
示例#11
0
 public bool Post(User user)
 {
     _db.Users.Add(user);
     return(_db.SaveChanges() == 1);
 }