public async Task <IActionResult> Create([Bind("ProductId,ProductType,ProductPrice,ProductName,ProductCalories,ProductDetails")] CafeProducts cafeProducts)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cafeProducts);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Menu)));
            }
            return(View(cafeProducts));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("CustomerId")] Customers customers)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customers));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("ProductId,ProductDetails,Price,Quantity,Reordering,MinimumStock")] Products products)
        {
            if (ModelState.IsValid)
            {
                _context.Add(products);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(products));
        }
        public async Task <IActionResult> Create([Bind("OrderId,OrderDate,CustomerId")] Orders orders)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orders);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustomerId", orders.CustomerId);
            return(View(orders));
        }
        public async Task <IActionResult> Create([Bind("OrderId,ProductId,Quantity,ProductOrderPrice")] CafeOrderDetails cafeOrderDetails)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cafeOrderDetails);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"]   = new SelectList(_context.CafeOrders, "OrderId", "OrderId", cafeOrderDetails.OrderId);
            ViewData["ProductId"] = new SelectList(_context.CafeProducts, "ProductId", "ProductId", cafeOrderDetails.ProductId);
            return(View(cafeOrderDetails));
        }
Beispiel #6
0
        public async Task <IActionResult> CreateProduct(CafeProducts product)
        {
            if (ModelState.IsValid)
            {
                CafeProducts lastProduct = _context.CafeProducts.LastOrDefault(c => c.ProductId == c.ProductId);

                if (lastProduct != null)
                {
                    product.ProductId = lastProduct.ProductId + 1;
                }
                else
                {
                    product.ProductId = 1;
                }
                _context.Add(product);
                await _context.SaveChangesAsync();

                ViewBag.Success = true;
                return(View());
            }
            return(View());
        }
        public async Task <IActionResult> Create([Bind("CustId,CustFirstName,CustSurName")] CafeCustomers cafeCustomers)
        {
            var LastEmployee = _context.CafeCustomers.OrderByDescending(c => c.CustId).FirstOrDefault();

            if (LastEmployee == null)
            {
                cafeCustomers.CustId = 1;
            }
            else
            {
                cafeCustomers.CustId = LastEmployee.CustId + 1;
            }

            if (ModelState.IsValid)
            {
                _context.Add(cafeCustomers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cafeCustomers));
        }