Esempio n. 1
0
        public async Task <IActionResult> Create([Bind("ProductID,ProductName,PurchasePrice,SellingPrice")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("CustomerID,FirstName,LastName,City")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("OrdersID,CustomerID,ProductID,QuantityOfProduct,OrderDate")] Orders orders)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orders);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerID"] = new SelectList(_context.Customer, "CustomerID", "CustomerID", orders.CustomerID);
            ViewData["ProductID"]  = new SelectList(_context.Set <Product>(), "ProductID", "ProductName", orders.ProductID);
            return(View(orders));
        }