Example #1
0
        public ActionResult Create(GalleryCreateEditModel galleryCreateEditModel)
        {
            Gallery gallery = new Gallery();

            if(ModelState.IsValid)
            {
                gallery.Id = Guid.NewGuid();
                gallery.Folder = galleryCreateEditModel.Folder;
                gallery.Title = galleryCreateEditModel.Title;
                gallery.ModelId = galleryCreateEditModel.SelectedModel;
                gallery.DatePublished = galleryCreateEditModel.DatePublished;
                gallery.URL = galleryCreateEditModel.URL;
                gallery.IsActive = false;
                db.Galleries.Add(gallery);
                db.SaveChanges();

                // Create Gallery Folder
                string basePath = "Content/Models/" + gallery.GetModelName(gallery.ModelId).Replace(" ", string.Empty) + "/ImageGalleries";
                DirectoryInfo dInfo = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + basePath);
                dInfo.CreateSubdirectory(gallery.Folder.Replace(" ", string.Empty));

                return RedirectToAction("Manage");
            }

            return View(gallery);
        }
Example #2
0
 // UI Automation Create
 public void CreateGallery(Gallery gallery)
 {
     if(ModelState.IsValid)
     {
         db.Galleries.Add(gallery);
         db.SaveChanges();
     }
 }