public ActionResult Create(CreateGalleryViewModel galleryViewModel) { if (ModelState.IsValid) { GalleryService galleryService = new GalleryService(); PhotoUploader photoUploader = new PhotoUploader(); Gallery gallery = galleryService.CreateGallery(galleryViewModel.GalleryName, galleryViewModel.Description); repository.Add(gallery); repository.Save(); gallery.Path = Server.MapPath("/Photos/" + gallery.Id); galleryService.CreateDirectoryStructure(gallery.Path); List<Photo> photos = photoUploader.UploadMultiplePhotos(galleryViewModel.PhotoUpload, gallery.Id); repository.AddPhotos(photos); repository.Save(); return RedirectToAction("ViewGallery", "Gallery", new {id = gallery.Id}); } return View(new CreateGalleryViewModel()); }
public ActionResult DeleteConfirmed(int id) { Gallery gallery = repository.GetById(id); GalleryService galleryService = new GalleryService(); repository.Delete(gallery); galleryService.DeleteDirectory(gallery.Path); repository.Save(); return RedirectToAction("Index"); }