public async Task <IActionResult> Create([Bind("CategoryId,Description")] Category category) { if (ModelState.IsValid) { db.Add(category); await db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Create([Bind("ProductId,Description,PurchaseDate,Price,Available,CategoryId")] Product product) { if (ModelState.IsValid) { db.Add(product); await db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(db.Category, "CategoryId", "Description", product.CategoryId); return(View(product)); }