Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }