Exemplo n.º 1
0
        public ActionResult Add()
        {
            PhotoRepository rep         = this.GetPhotoRepository();
            PhotosModel     photosModel = new PhotosModel()
            {
                PicCount     = rep.GetImagesCount(),
                Categorieses = rep.GetCategories(),
                CatCount     = rep.GetCategories().Count,
            };

            return(View("Add", photosModel));
        }
Exemplo n.º 2
0
        public ActionResult Index(string theme)
        {
            if (!string.IsNullOrWhiteSpace(theme))
            {
                string dir = Server.MapPath("content/themes/" + theme); //make sure theme dir exists
                if (Directory.Exists(dir))
                {
                    Session["theme"] = theme;
                }
            }

            string            re  = Request.RawUrl;
            GalleryRepository rep = this.GetGalleryRepository();

            ViewBag.Folders = rep.Folders;

            var photoRepository = new PhotoRepository();

            PhotosModel photosModel = new PhotosModel()
            {
                PicCount = photoRepository.GetImagesCount()
                           //    Categorieses = photoRepository.GetCategories()
            };

            ViewBag.Categories = photoRepository.GetCategories();


            ViewBag.HtmlContent = rep.RootFolder.GetHtmlContentIfAny(); //initial html content from root folder
            return(View("Index"));
        }
Exemplo n.º 3
0
        //[OutputCache(Duration = 0, VaryByParam = "folder")] //carefull, don't use cache here, different responses whatever is ajax request or not!
        public ActionResult List(int iCat)
        {
            PhotoRepository rep = this.GetPhotoRepository();
            //string vPathFolder = Util.StripFirstSlashFromVirtualPath(HttpUtility.UrlDecode(folder));

            var images = rep.GetCategoryImages(iCat);

            if (images == null)
            {
                Response.StatusCode = 400;
                return(Json(new { error = "Error, category not found on id: " + iCat }, JsonRequestBehavior.AllowGet));
            }


            ////check security
            //if (!pgfolder.IsUserGranted(User.Identity.Name)) {
            //        Response.StatusCode = 403;
            //        return Json(new { error = "This is a private folder. You need access to read its content." }, JsonRequestBehavior.AllowGet);
            //}

            //string content = pgfolder.GetHtmlContentIfAny();

            System.Collections.ArrayList list = new System.Collections.ArrayList();
            foreach (var image in images)
            {
                list.Add(new
                {
                    VPath        = Util.GetApplicationFullUrlWithoutLastSlash() + "/ImageView?ImageVPath=" + HttpUtility.UrlEncode(image.PIC_IMAGE),
                    UrlThumbnail = Util.GetApplicationFullUrlWithoutLastSlash() + "/ThumbnailView/120/120?ImageVPath=" + HttpUtility.UrlEncode(image.PIC_IMAGE),
                    Url          = HttpContext.Request.ApplicationPath.TrimEnd('/') + "/Image/" + image.PIC_ID,
                    UrlFullImage = Util.GetApplicationFullUrlWithoutLastSlash() + "/ImageView?ImageVPath=" + HttpUtility.UrlEncode(image.PIC_IMAGE),
                    Name         = image.PIC_NAME,
                });
            }

            string content = "";

            if (images.Count == 0)
            {
                return(View("../PHOTOS/Index"));
            }


            if (Request.IsAjaxRequest())
            {
                return(Json(new { thumbnails = list, htmlcontent = content }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                ViewBag.SelectedImage    = "Image/" + images[0].PIC_ID;
                ViewBag.Categories       = rep.GetCategories();
                ViewBag.SelectedCategory = Util.GetApplicationFullUrlWithoutLastSlash() + "/PHOTOS/Category/List/" + iCat;

                return(View("../PHOTOS/Index"));
            }
        }
Exemplo n.º 4
0
        //
        // GET: /Photos/

        public ViewResult Index()
        {
            var photoRepository = new PhotoRepository();

            PhotosModel photosModel = new PhotosModel()
            {
                PicCount     = photoRepository.GetImagesCount(),
                Categorieses = photoRepository.GetCategories()
            };

            return(View("IndexPhoto", photosModel));
        }
Exemplo n.º 5
0
        public ActionResult Main()
        {
            string            re  = Request.RawUrl;
            GalleryRepository rep = this.GetGalleryRepository();

            ViewBag.Folders = rep.Folders;

            var photoRepository = new PhotoRepository();

            //PhotosModel photosModel = new PhotosModel()
            //{
            //    PicCount = photoRepository.GetImagesCount()
            //    //    Categorieses = photoRepository.GetCategories()

            //};

            ViewBag.Categories = photoRepository.GetCategories();


            ViewBag.HtmlContent = rep.RootFolder.GetHtmlContentIfAny(); //initial html content from root folder
            return(View("Index"));
        }
Exemplo n.º 6
0
        //[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"));
            }
        }