public ActionResult Create(FormCollection data) { if (ModelState.IsValid) { Exhibit ex = new Exhibit { Name = data["Name"], Date = Convert.ToDateTime(data["Date"]), Location = data["Location"], ArtKeys = data["Selects"], Gallery = ArtsDb.GetArtsByString(db, data["Selects"]) }; if (!ExhibitsDb.HasExhibit(db, ex.Name)) { db.DbExhibit.Add(ex); db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("Name", "This name has been used already."); } } return(View(data)); }
// GET: Exhibits/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Exhibit exhibit = db.DbExhibit.Find(id); if (exhibit == null) { return(HttpNotFound()); } exhibit.Gallery = ArtsDb.GetArtsByString(db, exhibit.ArtKeys); return(View(exhibit)); }
public ActionResult Edit(FormCollection data) { if (ModelState.IsValid) { Exhibit ex = new Exhibit { Name = data["Name"], Date = Convert.ToDateTime(data["Date"]), Location = data["Location"], ArtKeys = data["Selects"], Gallery = ArtsDb.GetArtsByString(db, data["Selects"]) }; db.Entry(ex).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(data)); }