// GET: Home/Details/5 public ActionResult Details(int id) { return(View(repo.GetImage(id))); }
//[OutputCache(Duration = 0, VaryByParam = "ImageVPath")] //don't use cache here (ajax and html responses) public ActionResult Index(int id) { PhotoRepository rep = this.GetPhotoRepository(); ////ImageVPath = HttpUtility.UrlDecode(ImageVPath); ////if (ImageVPath[0] == '/') ////{ //// ImageVPath = ImageVPath.Substring(1); ////} PIC_IMAGES image = rep.GetImage(id); //if (image != null) //{ // string cacheKey = "exif" + id; // if (HttpContext.Cache[cacheKey] = null) // { // image.EXIF = HttpContext.Cache[cacheKey] as EXIF; // } // else // { // //exif info // ExifReader r = new ExifReader(image.PhysicalPath); //file is String // r.FillPGImage(ref image); // HttpContext.Cache.Add(cacheKey, image.EXIF, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 10, 0), CacheItemPriority.Normal, null); // } // PGImage imagePrev=null; //prev img? // PGImage nextImg=null; //next img? // if (image.ParentFolder != null) { // imagePrev = rep.GetPreviousImage(image); // nextImg = rep.GetNextImage(image); // } var imageJson = new { //ImageMainPage = image.MainPageFullUrl, ImageVPath = Util.GetApplicationFullUrlWithoutLastSlash() + "/ImageView?ImageVPath=" + HttpUtility.UrlEncode(image.PIC_IMAGE), ImageFriendlyName = image.PIC_NAME, ImageDescr = image.PIC_DESC, Name = image.PIC_NAME, //NextThumbnail = nextImg == null ? "" : nextImg.ImageThumbnailFullUrl, //NextImage = nextImg == null ? "" : nextImg.ImageFullUrl, //PrevThumbnail = imagePrev == null ? "" : imagePrev.ImageThumbnailFullUrl, //PrevImage = imagePrev == null ? "" : imagePrev.ImageFullUrl, //UrlThumbnail = image.ImageThumbnailFullUrl, //Url = image.ImageFullUrl, // Comments = image.Comments.OrderByDescending(c => c.TimeStamp), // EXIF = image.EXIF, }; if (Request.IsAjaxRequest()) { return(Json(imageJson, JsonRequestBehavior.AllowGet)); } else { ViewBag.SelectedImage = "Image/" + image.PIC_ID; ViewBag.Categories = rep.GetCategories(); ViewBag.SelectedCategory = Util.GetApplicationFullUrlWithoutLastSlash() + "/PHOTOS/Category/List/" + image.PIC_CAT; return(View("../PHOTOS/Index")); } }