public async Task <IActionResult> Create([Bind("LocationID,Name,AddressNum,AddressStreet,AddressCity,AddressState,AddressZipCode,Description")] Location location)
        {
            if (ModelState.IsValid)
            {
                _context.Add(location);
                await _context.SaveChangesAsync();

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

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
        public async Task <IActionResult> Create([Bind("ProductID,Name,Price,Type,Description")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("Username,Password,CustomerID")] UserAccount userAccount)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userAccount);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerID"] = new SelectList(_context.Customers, "CustomerID", "CustomerID", userAccount.CustomerID);
            return(View(userAccount));
        }
        public async Task <IActionResult> Create([Bind("OrderID,CustomerID,LocationID,OrderTime,BillingID,ShippingID")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BillingID"]  = new SelectList(_context.BillingInformation, "BillingID", "AddressCity", order.BillingID);
            ViewData["CustomerID"] = new SelectList(_context.Customers, "CustomerID", "CustomerID", order.CustomerID);
            ViewData["LocationID"] = new SelectList(_context.Locations, "LocationID", "LocationID", order.LocationID);
            ViewData["ShippingID"] = new SelectList(_context.ShippingInformation, "ShippingID", "AddressCity", order.ShippingID);
            return(View(order));
        }