public async Task <IActionResult> Create([Bind("Id,Name")] Types types) { if (ModelState.IsValid) { _context.Add(types); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(types)); }
public async Task <IActionResult> Create([Bind("Id,Name,Info,Cost,Year,FormId,MaterialId,TypeId,BrandId")] Guitars guitars) { if (ModelState.IsValid) { _context.Add(guitars); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BrandId"] = new SelectList(_context.Brands, "Id", "Name", guitars.BrandId); ViewData["FormId"] = new SelectList(_context.Forms, "Id", "Name", guitars.FormId); ViewData["MaterialId"] = new SelectList(_context.Materials, "Id", "Name", guitars.MaterialId); ViewData["TypeId"] = new SelectList(_context.Types, "Id", "Name", guitars.TypeId); return(View(guitars)); }