public async Task <IActionResult> Create([Bind("Id", "Name")] Category category) { if (ModelState.IsValid) { context.Add(category); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Create([Bind("Id,CategoryId,ProductName,ProductPrice,InsertedDate,UpdatedDate")] Product product) { if (ModelState.IsValid) { context.Add(product); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(context.Categories, "Id", "Name", product.CategoryId); return(View(product)); }