public ActionResult Create([Bind(Include = "Id,Name")] Astronomer astronomer) { if (ModelState.IsValid) { db.Astronomers.Add(astronomer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(astronomer)); }
public ActionResult Create([Bind(Include = "Id,Name,Constellation,GalaxyType,ApparentMagnitude,RightAscension,Declination,AstronomerId")] Galaxy galaxy) { if (ModelState.IsValid) { db.Galaxies.Add(galaxy); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AstronomerId = new SelectList(db.Astronomers, "Id", "Name", galaxy.AstronomerId); return(View(galaxy)); }
public ActionResult Create([Bind(Include = "Id,Name,Constellation,ApparentMagnitude,RightAscension,Declination,AstronomerId,ClusterId")] Star star) { try { if (ModelState.IsValid) { db.Stars.Add(star); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AstronomerId = new SelectList(db.Astronomers, "Id", "Name", star.AstronomerId); ViewBag.ClusterId = new SelectList(db.Clusters, "Id", "Name", star.ClusterId); } catch (RetryLimitExceededException) { ModelState.AddModelError("", "Unable to save changes."); } return(View(star)); }