public async Task <IActionResult> Create([Bind("ID,FactoryName,Address")] Factory factory) { if (ModelState.IsValid) { _context.Add(factory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(factory)); }
public async Task <IActionResult> Create([Bind("Title,Description,Color,Price")] Furniture furniture) { try { if (ModelState.IsValid) { _context.Add(furniture); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException /* ex*/) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists "); } return(View(furniture)); }