public async Task <IActionResult> Create([Bind("Id,FactoryId,BladeName,Composite")] Blade blade) { if (ModelState.IsValid) { if (BladeExists(blade.BladeName)) { return(RedirectToAction(nameof(Index))); } _context.Add(blade); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["FactoryId"] = new SelectList(_context.Factory, "Id", "FactoryName", blade.FactoryId); return(View(blade)); }
public async Task <IActionResult> Create([Bind("Id,FactoryId,RubberName,Pimples")] Rubber rubber) { if (ModelState.IsValid) { if (RubberExists(rubber.FactoryId, rubber.RubberName)) { return(RedirectToAction(nameof(Index))); } _context.Add(rubber); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["FactoryId"] = new SelectList(_context.Factory, "Id", "FactoryName", rubber.FactoryId); return(View(rubber)); }