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));
        }
Esempio n. 2
0
        public ActionResult Index(string id)
        {
            // news data
            Exhibit ex = ExhibitsDb.GetNews(db);

            if (ex != null)
            {
                if (ex.Gallery.Count() > 0)
                {
                    ViewBag.NewsPath = ex.Gallery.Last().Path;
                }

                ViewBag.NewsName = ex.Name;
            }

            // Exhibits
            ArtViewModel vm = new ArtViewModel();

            vm.Exhibits   = ExhibitsDb.GetExhibitMap(db);
            vm.Paintings  = ArtsDb.GetAllPaintings(db);
            vm.Sculptures = ArtsDb.GetAllSculptures(db);

            // Gallery
            if (id != null)
            {
                Exhibit show = ExhibitsDb.GetExhibit(db, id);
                if (show != null)
                {
                    vm.Gallery = show.Gallery;
                }
                else
                {
                    vm.Gallery = ArtsDb.GetArtsByName(db, id);
                }
            }
            else
            {
                Exhibit show = ExhibitsDb.GetNews(db);
                if (show != null)
                {
                    vm.Gallery = show.Gallery;
                }
            }

            return(View(vm));
        }
 // GET: Exhibits
 public ActionResult Index()
 {
     return(View(ExhibitsDb.GetAllExhibits(db)));
 }