示例#1
0
        public async Task <IActionResult> Create([Bind("Id,TypeName,Price,Color,Weight,Unit")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,Fname,Lnam,City,Street,NumberHome")] 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,name,phone,email")] NewUser newUser)
        {
            if (ModelState.IsValid)
            {
                _context.Add(newUser);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(newUser));
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("Id,Color,Price,Type")] NewProduct newProduct)
        {
            if (ModelState.IsValid)
            {
                _context.Add(newProduct);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(newProduct));
        }
示例#5
0
        public async Task <IActionResult> Create([Bind("Id,CustomerId")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Set <Customer>(), "Id", "Id", order.CustomerId);
            return(View(order));
        }
示例#6
0
        public async Task <IActionResult> Create([Bind("id,OrderId,ProductId")] ProductOrder productOrder)
        {
            if (ModelState.IsValid)
            {
                _context.Add(productOrder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"]   = new SelectList(_context.NewOrder, "Id", "Id", productOrder.OrderId);
            ViewData["ProductId"] = new SelectList(_context.NewProduct, "Id", "Id", productOrder.ProductId);
            return(View(productOrder));
        }