public async Task <IActionResult> New(Customer customer) { if (ModelState.IsValid) { context.Add(customer); await context.SaveChangesAsync(); return(RedirectToAction("Index", "Products")); } return(BadRequest()); }
public async Task <IActionResult> New(Product product) { if (ModelState.IsValid) { context.Add(product); await context.SaveChangesAsync(); return(RedirectToAction("Index")); } //Make sure error messages are present in the view if the view is returned to the customer. return(BadRequest()); }