Exemplo n.º 1
0
        public void Post_AddGalleryImage(GalleryImagesViewModel vm, Controller ctrl)
        {
            string file_name  = "";
            string photo_name = DataLayer.get_lastPhoto_path(vm.GalleryID);

            if (photo_name != "")
            {
                int index_from = photo_name.LastIndexOf('_') + 1;
                int index_to   = photo_name.LastIndexOf('.');
                int photo_num  = Int32.Parse(photo_name.Substring(index_from, index_to - index_from)) + 1;
                file_name = vm.GalleryID + "_" + photo_num + ".jpg";
            }
            else
            {
                file_name = vm.GalleryID + "_1.jpg";
            }

            DataLayer.save_gallery_image(vm.GalleryID, file_name);

            string save_dir = ctrl.Server.MapPath(@"~\Upload\gallery_" + vm.GalleryID);

            if (!Directory.Exists(save_dir))
            {
                Directory.CreateDirectory(save_dir);
            }

            vm.image.SaveAs(save_dir + "\\" + file_name);
        }
Exemplo n.º 2
0
        public GalleryImagesViewModel Get_ArtGallery_Images(int id, int?page, Controller ctrl)
        {
            GalleryImagesViewModel vm = new GalleryImagesViewModel();

            int current_page = page.HasValue ? page.Value : 1;

            ctrl.TempData["page"] = current_page;

            List <string> str_images = DataLayer.get_gallery_images(id);

            for (int i = 0; i < str_images.Count; i++)
            {
                str_images[i] = ("gallery_" + id + "/" + str_images[i]);
            }

            IPagedList <string> paged_list_images = null;

            if (str_images != null)
            {
                paged_list_images = str_images.ToPagedList(current_page, pagesize_image);
            }

            vm.gallery_images = paged_list_images;
            vm.GalleryID      = id;
            vm.filter_page    = new SearchPaginationViewModel()
            {
                page = current_page
            };

            return(vm);
        }
        public ActionResult AddImage(HttpPostedFileBase image, int GalleryId, int page)
        {
            GalleryImagesViewModel vm = new GalleryImagesViewModel()
            {
                GalleryID = GalleryId,
                image     = image
            };

            NegahenoService.Post_AddGalleryImage(vm, this);

            return(Json(new { msg = "image uploaded successfully!", page_index = page, galleryID = GalleryId }));
        }
Exemplo n.º 4
0
        public void Post_AddGalleryPoster(GalleryImagesViewModel vm, Controller ctrl)
        {
            if (vm.image != null)
            {
                string save_dir = ctrl.Server.MapPath(@"~\Upload\gallery_" + vm.GalleryID);
                if (!Directory.Exists(save_dir))
                {
                    Directory.CreateDirectory(save_dir);
                }

                vm.image.SaveAs(save_dir + "\\poster.jpg");
            }
        }
        public ActionResult AddPoster(HttpPostedFileBase image, int GalleryId, string GalleryName, string filter, int page)
        {
            GalleryImagesViewModel vm = new GalleryImagesViewModel()
            {
                GalleryID   = GalleryId,
                GalleryName = GalleryName,
                image       = image
            };

            NegahenoService.Post_AddGalleryPoster(vm, this);

            return(Json(new { msg = "poster uploaded successfully!", page_index = page, filter = filter + "" }));
        }
        public ActionResult Images(int id, int?page)
        {
            GalleryImagesViewModel vm = NegahenoService.Get_ArtGallery_Images(id, page, this);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_PartialImagesList", vm.gallery_images));
            }
            else
            {
                return(View(vm));
            }
        }
Exemplo n.º 7
0
        public GalleryImagesViewModel Get_PartialPoster(int id, Controller ctrl)
        {
            GalleryImagesViewModel vm = new GalleryImagesViewModel();

            ArtGalleryViewModel gallery = DataLayer.get_ArtGallery_byID(id);

            vm.GalleryID   = id;
            vm.GalleryName = gallery.fa_title.Length > 50 ? (gallery.fa_title.Substring(0, 50) + "...") : gallery.fa_title;

            string poster_path = "/Upload/gallery_" + vm.GalleryID + "/poster.jpg";

            if (File.Exists(ctrl.Server.MapPath(@poster_path)))
            {
                vm.image_path = poster_path + "?" + DateTime.Now.ToString("ddMMyyyyhhmmsstt");
            }
            else
            {
                vm.image_path = "/images/empty.gif?" + DateTime.Now.ToString("ddMMyyyyhhmmsstt");
            }

            vm.filter_page = Get_SearchPagination_Params(ctrl);

            return(vm);
        }
        public ActionResult Get_PosterModal(int id)
        {
            GalleryImagesViewModel vm = NegahenoService.Get_PartialPoster(id, this);

            return(PartialView("_PartialAddPoster", vm));
        }