public void AddOrder(int user_id, int?location_id, decimal orderTotal)
        {
            var date_time = DateTime.Now;

            var order = new Orders
            {
                UsersId    = user_id,
                LocationId = location_id,
                OrderTotal = orderTotal,
                OrderTime  = date_time
            };

            _db.Add(order);
            SaveChanges();
        }
        public void AddPizzaTopping(int?pizza_id, int item_id)
        {
            var hasTopping = new PizzaTopping
            {
                PizzaId = pizza_id,
                ItemId  = item_id
            };

            _db.Add(hasTopping);
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("LocationId,Name")] Locations locations)
        {
            if (ModelState.IsValid)
            {
                _context.Add(locations);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(locations));
        }
        public async Task <IActionResult> Create([Bind("PizzaId,Name,Type,Size,Crust,Price")] Pizzas pizzas)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pizzas);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(pizzas));
        }
Example #5
0
        public async Task <IActionResult> Create([Bind("UsersId,FirstName,LastName,LocationId,Phone")] Users users)
        {
            if (ModelState.IsValid)
            {
                _context.Add(users);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(users));
        }
Example #6
0
        public async Task <IActionResult> Create([Bind("ItemId,Name,IsTopping,Quantity,LocationId")] Inventory inventory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(inventory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LocationId"] = new SelectList(_context.Locations, "LocationId", "Name", inventory.LocationId);
            return(View(inventory));
        }
        public async Task <IActionResult> Create([Bind("Id,OrderId,PizzaId,Quantity")] OrderPizza orderPizza)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orderPizza);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"] = new SelectList(_context.Orders, "OrderId", "OrderId", orderPizza.OrderId);
            ViewData["PizzaId"] = new SelectList(_context.Pizzas, "PizzaId", "Name", orderPizza.PizzaId);
            return(View(orderPizza));
        }
        public async Task <IActionResult> Create([Bind("OrderId,UsersId,LocationId,OrderTime,Price,OrderTotal")] Orders orders)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orders);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LocationId"] = new SelectList(_context.Locations, "LocationId", "Name", orders.LocationId);
            ViewData["UsersId"]    = new SelectList(_context.Users, "UsersId", "FirstName", orders.UsersId);
            return(View(orders));
        }