public ActionResult Create(Rating rating) { if (ModelState.IsValid) { db.Ratings.Add(rating); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.IssueID = new SelectList(db.Issues, "IssueID", "title", rating.IssueID); return View(rating); }
// // GET: /Ratings/Create public ActionResult Create(int id) { //TODO:: check to see if the user has a rating, if they do forward to edit instead! Issue issue = db.Issues.Include("Series").Single(i => i.IssueID==id); ViewBag.IssueTitle = issue.series.name + " " + issue.number; //new SelectList(db.Issues.Include("Series"), "IssueID", "series.name number"); ViewBag.IssueID = id; var model = new Rating { user = User.Identity.Name, IssueID = id }; return View(model); }
public ActionResult Edit(Rating rating) { if (ModelState.IsValid) { db.Entry(rating).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.IssueID = new SelectList(db.Issues, "IssueID", "title", rating.IssueID); return View(rating); }