示例#1
0
        public async Task <IActionResult> Create([Bind("Id,Username,Password,Firstname,Lastname,Phone,Email,IsReviewer,IsAdmin")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,Code,Name,Address,City,State,Zip,Phone,Email")] Vendor vendor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vendor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vendor));
        }
        public async Task <IActionResult> Create([Bind("Id,PartNbr,Name,Price,Unit,Photopath,VendorId")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VendorId"] = new SelectList(_context.Vendors, "Id", "Address", product.VendorId);
            return(View(product));
        }