Beispiel #1
0
        public ActionResult Gallery(GalleryVM gallery)
        {
            if (gallery != null && gallery.Images != null)
            {
                using (Repository r = new Repository())
                {
                    foreach (var image in r.Files)
                    {
                        var i = gallery.Images.Find(x => x.ID == image.ID.ToString());

                        if (i == null)
                        {
                            r.Files.Remove(image);
                        }
                        else
                        {
                            image.Description = i.Description;
                        }
                    }

                    r.SaveChanges();
                }
            }
            return View(GetGalleryVM());
        }
Beispiel #2
0
 private GalleryVM GetGalleryVM()
 {
     GalleryVM vm = new GalleryVM();
     vm.Images = new List<GalleryImageVM>();
     using (Repository r = new Repository())
     {
         foreach (var f in r.Files)
         {
             vm.Images.Add(
                 new GalleryImageVM()
                 {
                     ID = f.ID.ToString(),
                     Url = Url.Action("DownloadFile", "Home", new { id = f.ID }),
                     DeleteUrl = Url.Action("DeleteFile", new { id = f.ID }),
                     Name = f.Name,
                     Description = f.Description
                 });
         }
     }
     return vm;
 }