public ActionResult Create(int Page_ID, string Gallery_Name)
        {
            if (ModelState.IsValid)
            {
                Gallery gal = new Gallery();
                gal.Gallery_Name = Gallery_Name;
                gal.Date_Added   = DateTime.Now;
                gal.Added_By     = User.Identity.Name.ToString();///TODO: auth
                gal.Archived     = false;
                db.Galleries.Add(gal);
                db.SaveChanges();

                PageGalleryAssign galAss = new PageGalleryAssign();
                galAss.Gallery    = gal;
                galAss.Page_ID    = Page_ID;
                galAss.Date_Added = DateTime.Now;
                galAss.Added_By   = User.Identity.Name.ToString();///TODO: auth
                galAss.Archived   = false;
                db.PageGalleryAssigns.Add(galAss);

                db.SaveChanges();
                return(RedirectToAction("Edit", new { Page_ID = Page_ID, Gallery_ID = gal.Gallery_ID }));
            }
            else
            {
                ModelState.AddModelError("", "Error. Invalid Model State. Please try again.");
                GalleryCreateViewModel viewMod = new GalleryCreateViewModel(Page_ID);
                viewMod.Gallery_Name = Gallery_Name;
                return(View(viewMod));
            }
        }
Beispiel #2
0
        public ActionResult RemoveImageGallery(int Page_ID, int Gallery_ID)
        {
            PageGalleryAssign gal = db.PageGalleryAssigns.Where(x => x.Gallery_ID == Gallery_ID && x.Page_ID == Page_ID).FirstOrDefault();

            if (gal == null)
            {
                return(HttpNotFound());
            }
            gal.Archive_By   = User.Identity.Name.ToString();///TODO: auth
            gal.Date_Archive = DateTime.Now;
            gal.Archived     = true;
            db.SaveChanges();
            return(RedirectToAction("Edit", new { id = Page_ID }));
        }