Ejemplo n.º 1
0
        public ActionResult AddImage(int id, HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                // TODO add thumbnail generation - probably a separate class, after
                Gallery gallery = galleriesRepository.Galleries.Find(id);
                GalleryFolder galleryFolder = new GalleryFolder(gallery.Path);
                galleryFolder.AddFile(file);
            }

            return RedirectToAction("Edit", new { id });
        }
Ejemplo n.º 2
0
        public ActionResult Create(GalleryNew galleryNew)
        {
            if (ModelState.IsValid)
            {
                GalleryFolder galleryFolder = new GalleryFolder(galleryNew.Title);
                string galleryPath = galleryFolder.CreateGalleryDirectories();

                Gallery gallery = new Gallery { Path = galleryPath };
                gallery.InjectFrom(galleryNew);
                galleriesRepository.Galleries.Add(gallery);
                galleriesRepository.SaveChanges();

                return RedirectToAction("Index");
            }

            return View(galleryNew);
        }
Ejemplo n.º 3
0
        public ActionResult DeleteGallery(int id)
        {
            if (ModelState.IsValid)
            {
                Gallery galleryToDelete = galleriesRepository.Galleries.Find(id);
                galleriesRepository.Galleries.Remove(galleryToDelete);
                galleriesRepository.SaveChanges();

                try
                {
                    GalleryFolder galleryFolder = new GalleryFolder(galleryToDelete.Path);
                    galleryFolder.DeleteGalleryFolders();
                }
                catch
                {
                }

                return RedirectToAction("Index");
            }

            return View("Index");
        }