Пример #1
0
 private StoreSingleton(PizzaBoxContext context)
 {
     _context = context;
     Stores   = _context.Stores.ToList();
     if (Stores == null)
     {
         var s = new ChicagoStore();
         var n = new NewYorkStore();
         _context.Add(s);
         _context.Add(n);
     }
     //Stores = _context.Stores.ToList();
 }
 public long AddCustomer(Customer customer)
 {
     //_context.Sizes.FirstOrDefault(s => s.Name == "Medium")
     _context.Add(customer);
     _context.SaveChanges();
     return(_context.Customers.FirstOrDefault(s => s.Name == customer.Name).EntityId);
 }
Пример #3
0
        public async Task <IActionResult> Create([Bind("Id,Topping,Price,Amount,Type")] Ingredients ingredients)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ingredients);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ingredients));
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("Id,OrderId,Amount")] Pizza pizza)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pizza);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"] = new SelectList(_context.Orders, "Id", "Id", pizza.OrderId);
            return(View(pizza));
        }
        public async Task <IActionResult> Create([Bind("Id,PizzaId,IngredientId,Finished")] PizzaIngredients pizzaIngredients)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pizzaIngredients);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IngredientId"] = new SelectList(_context.Ingredients, "Id", "Topping", pizzaIngredients.IngredientId);
            ViewData["PizzaId"]      = new SelectList(_context.Pizza, "Id", "Id", pizzaIngredients.PizzaId);
            return(View(pizzaIngredients));
        }
Пример #6
0
        public async Task <IActionResult> Create([Bind("Id,TotalPrice,OrderStatus,PlaceDate,DeliveryDate,StoreId,EmployeeId,CustomerId")] Orders orders)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orders);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "Id", "FirstName", orders.CustomerId);
            ViewData["EmployeeId"] = new SelectList(_context.Employee, "Id", "Username", orders.EmployeeId);
            ViewData["StoreId"]    = new SelectList(_context.Store, "Id", "Id", orders.StoreId);
            return(View(orders));
        }
Пример #7
0
        public void AddOrder(Order order)
        {
            //_context.Sizes.FirstOrDefault(s => s.Name == "Medium")
            order.Store       = _context.Stores.FirstOrDefault(s => s.Name == order.Store.Name);
            order.Pizza.Crust = _context.Crusts.FirstOrDefault(s => s.Name == order.Pizza.Crust.Name);
            order.Pizza.Size  = _context.Sizes.FirstOrDefault(s => s.Name == order.Pizza.Size.Name);

            var temp = new List <Topping>();

            foreach (var item in order.Pizza.Toppings)
            {
                temp.Add(_context.Toppings.FirstOrDefault(s => s.Name == item.Name));
            }
            order.Pizza.Toppings = temp;

            order.Pizza    = _context.Pizzas.FirstOrDefault(s => s.EntityId == order.Pizza.EntityId);
            order.Customer = _context.Customers.FirstOrDefault(s => s.EntityId == order.Customer.EntityId);
            _context.Add(order);
            _context.SaveChanges();
        }
Пример #8
0
 public void Save(Store store)
 {
     _db.Add(store);    // git add
     _db.SaveChanges(); // git commit
 }
Пример #9
0
 public void AddOrder(Order Order)
 {
     _context.Add(Order);
 }
Пример #10
0
 public void MakePizza(Pizza pizza)
 {
     _ptx.Add <Pizza>(pizza);
     _ptx.SaveChanges();
 }
Пример #11
0
 public void AddUser(User User)
 {
     _context.Add(User);
 }