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));
        }
        public ActionResult Create()
        {
            ExhibitsViewModel vm = new ExhibitsViewModel();

            vm.ArtList = ArtsDb.GetCurrentArts_SelectListItems(db);
            return(View(vm));
        }
        // 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));
        }
示例#4
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));
        }
        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));
        }
        // GET: Exhibits/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Exhibit ex = db.DbExhibit.Find(id);

            if (ex == null)
            {
                return(HttpNotFound());
            }

            ExhibitsViewModel vm = new ExhibitsViewModel
            {
                Name     = ex.Name,
                Date     = ex.Date,
                Location = ex.Location,
                ArtList  = ArtsDb.GetCurrentArts_SelectListItems(db)
            };

            return(View(vm));
        }