public async Task <IActionResult> Create([Bind("Id,CompanyName,ContactName,ContactTitle,City,Country,Phone,Fax")] Supplier supplier)
        {
            if (ModelState.IsValid)
            {
                _context.Add(supplier);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(supplier));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,City,Country,Phone")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("Id,OrderDate,OrderNumber,CustomerId,TotalAmount")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "Id", "FirstName", order.CustomerId);
            return(View(order));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("Id,ProductName,SupplierId,UnitPrice,Package,IsDiscontinued")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SupplierId"] = new SelectList(_context.Supplier, "Id", "CompanyName", product.SupplierId);
            return(View(product));
        }
예제 #5
0
        public async Task <IActionResult> Create([Bind("Id,OrderId,ProductId,UnitPrice,Quantity")] OrderItem orderItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orderItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"]   = new SelectList(_context.Order, "Id", "Id", orderItem.OrderId);
            ViewData["ProductId"] = new SelectList(_context.Product, "Id", "ProductName", orderItem.ProductId);
            return(View(orderItem));
        }