public async Task <IActionResult> Create([Bind("Id,Name")] Track track) { if (ModelState.IsValid) { _context.Add(track); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(track)); }
public async Task <IActionResult> Create([Bind("Id,Name,Address,City,State,Zip")] Location location) { if (ModelState.IsValid) { _context.Add(location); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(location)); }
public async Task <IActionResult> Create(Student student) { var trackId = int.Parse(Request.Form["Track"]); Track track = _context.Tracks.Single(t => t.Id == trackId); student.Track = track; var locationId = int.Parse(Request.Form["Location"]); Location location = _context.Locations.Single(l => l.Id == locationId); student.Location = location; if (ModelState.IsValid) { _context.Add(student); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Tracks"] = getTracksDropDown(); ViewData["Locations"] = getLocationsDropDown(); return(View(student)); }