public async Task <IActionResult> Create([Bind("CategoryId,Name")] Categories categories)
        {
            if (ModelState.IsValid)
            {
                _context.Add(categories);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(categories));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("OrderId,OrderDate,UserId,Total,FirstName,LastName,Address,City,Province,PostalCode,Phone")] Orders orders)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orders);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(orders));
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("ProductId,Name,Description,Price,Photo,CategoryId")] Products products)
        {
            if (ModelState.IsValid)
            {
                _context.Add(products);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "Name", products.CategoryId);
            return(View(products));
        }