GetGallery() public method

public GetGallery ( int galleryId ) : dynamic
galleryId int
return dynamic
Beispiel #1
0
        public ActionResult Thumbnail(int id)
        {
            var db = new PhotoGalleryRepository();

            var gallery = db.GetGallery(id);
            if (gallery == null)
            {
                return HttpNotFound();
            }

            var photos = db.GetTopPhotosForGallery(id);
            if (photos.Count == 0)
            {
                return File(Server.MapPath("~/Content/Images/gallery-empty.png"), "image/jpeg");
            }

            using (var generator = new MultiThumbnailGenerator())
            {
                foreach (var photo in photos)
                {
                    using (var imageStream = new MemoryStream(photo.FileContents))
                    {
                        using (var image = System.Drawing.Image.FromStream(imageStream))
                        {
                            generator.AddImage(image);
                        }
                    }
                }
                using (var outStream = new MemoryStream())
                {
                    generator.WritePngToStream(outStream);
                    var image = new WebImage(outStream);
                    image.Write();

                    return null;
                }
            }
        }
Beispiel #2
0
        public ActionResult View(int? id)
        {
            if (!id.HasValue)
                return RedirectToRoute("Default");

            var photoDB = new PhotoGalleryRepository();
            var tagDB = new TagRepository();
            var userDB = new UserRepository();

            var photo = photoDB.GetPhoto(id.Value);
            if (photo == null)
                return HttpNotFound();

            ViewBag.Title = "Photo - " + photo.FileTitle;

            dynamic model = new ExpandoObject();
            model.Photo = photo;
            model.User = userDB.GetUserById(photo.UserId);
            model.Gallery = photoDB.GetGallery(photo.GalleryId);
            model.Comments = photoDB.GetCommentsByPhoto(photo.Id);
            model.TagList = tagDB.GetTagListByPhoto(photo.Id);

            return View("View", model);
        }
Beispiel #3
0
        public ActionResult View(int id)
        {
            var db = new PhotoGalleryRepository();

            var gallery = db.GetGallery(id);
            if (gallery == null)
                return HttpNotFound();

            var photos = db.GetPhotosForGallery(id);

            ViewBag.Title = "Gallery - " + gallery.Name;
            ViewBag.Name = gallery.Name;
            ViewBag.GalleryId = id;

            return View(photos);
        }
Beispiel #4
0
        public ActionResult Upload(int id)
        {
            WebSecurity.RequireAuthenticatedUser();

            var db = new PhotoGalleryRepository();
            var gallery = db.GetGallery(id);

            if (gallery == null)
                return HttpNotFound();

            ViewBag.Title = "Upload Photo to Gallery - " + gallery.Name;

            return View(gallery);
        }