Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("CustomerId,FirstName,LastName,Address,Phone,City,State,Zipcode")] Customers customers)
        {
            if (id != customers.CustomerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomersExists(customers.CustomerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customers));
        }
        public async Task <IActionResult> Create([Bind("StoreId,Name,Phone,Email,Street,City,State,ZipCode")] StoreLoc storeLoc)
        {
            if (ModelState.IsValid)
            {
                _context.Add(storeLoc);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(storeLoc));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("OrderId,FoodId,Name,Price,OrderTime,StoreId,CustomerId")] Orders orders, int quantity, int foodid)
        {
            TempData["Cart"] = null;
            if (ModelState.IsValid)
            {
                orders.Name      = _context.Foods.Find(foodid).Name;
                orders.OrderTime = DateTime.Now;
                _context.Add(orders);
                await _context.SaveChangesAsync();

                TempData["LocID"]  = orders.StoreId;
                TempData["CustID"] = orders.CustomerId;
                return(RedirectToAction("AddOrderItem", new { productId = foodid, quantity = quantity }));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "FirstName", orders.CustomerId);
            ViewData["StoreId"]    = new SelectList(_context.StoreLoc, "StoreId", "Name", orders.StoreId);
            ViewData["FoodId"]     = new SelectList(_context.StoreLoc, "FoodId", "Name", orders.FoodId);
            return(View(orders));
        }