Ejemplo n.º 1
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"));
            }
        }
Ejemplo n.º 2
0
        public ViewResult Index()
        {
            EventRepository        eventRepository        = new EventRepository();
            PhotoRepository        photoRepository        = new PhotoRepository();
            AnnouncementRepository announcementRepository = new AnnouncementRepository();

            var homeModel = new HomeModel()
            {
                LatestAnnouncements      = announcementRepository.GetLatestAnnouncements(4).ToList(),
                ActiveAnnouncementsCount = announcementRepository.GetActiveAnnouncements().Count(),
                LatestEvents             = eventRepository.GetLatestEvents(6).ToList(),
                LatestNews   = eventRepository.GetLatestNews(3).ToList(),
                latestPhotos = photoRepository.GetCategoryImages(38)
            };

            //   ViewBag.FullUrl = Util.GetApplicationFullUrlWithoutLastSlash();

            return(View(homeModel));
        }