Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Cid,Name,Age,Phone")] Customers customers)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customers));
        }
        public async Task <IActionResult> Create([Bind("Pid,ProductName,Description,Price,Rating,Category")] Products products)
        {
            if (ModelState.IsValid)
            {
                _context.Add(products);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(products));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Oid,Cid,Pid,PurchaseDate,PaymentDate")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Cid"] = new SelectList(_context.Customers, "Cid", "Cid", order.Cid);
            ViewData["Pid"] = new SelectList(_context.Products, "Pid", "Pid", order.Pid);
            return(View(order));
        }