Пример #1
0
        public ActionResult DeleteGallery(int postId, int galleryId)
        {
            ActionResult actionResult;

            if (!Request.IsAjaxRequest())
            {
                return(Json(new { success = false }));
            }
            try
            {
                var galleryImage = _galleryService.Get(x => x.PostId == postId && x.Id == galleryId);
                _galleryService.Delete(galleryImage);

                var path1 = Server.MapPath(string.Concat("~/", galleryImage.ImageBig));
                var path2 = Server.MapPath(string.Concat("~/", galleryImage.ImageThumbnail));

                System.IO.File.Delete(path1);
                System.IO.File.Delete(path2);

                actionResult = Json(new { success = true });
            }
            catch (Exception ex)
            {
                actionResult = Json(new { success = false, messages = ex.Message });
            }
            return(actionResult);
        }
Пример #2
0
        public async Task <IActionResult> Index()
        {
            ViewBag.Current = "Random";

            var uri = await _galleryService.GenerateGalleryUri(24);

            var gallery = await _galleryService.Get(uri);

            var vm = SinglePageGenerator.Generate(gallery);

            vm.GalleryTitle = "Randomized";

            return(View("Index", vm));
        }
Пример #3
0
        public ActionResult DeleteGallery(int postId, int galleryId)
        {
            ActionResult actionResult;

            if (Request.IsAjaxRequest())
            {
                try
                {
                    if (_postService.Get(x => x.Id == postId && x.CreatedBy.Equals(HttpContext.User.Identity.Name)) == null)
                    {
                        return(Json(new { success = false }));
                    }

                    var galleryImage = _galleryService.Get(x => x.PostId == postId && x.Id == galleryId);
                    _galleryService.Delete(galleryImage);
                    var str  = Server.MapPath(string.Concat("~/", galleryImage.ImageBig));
                    var str1 = Server.MapPath(string.Concat("~/", galleryImage.ImageThumbnail));
                    System.IO.File.Delete(str);
                    System.IO.File.Delete(str1);
                    actionResult = Json(new { success = true });
                }
                catch (Exception exception1)
                {
                    var exception = exception1;
                    actionResult = Json(new { success = false, messages = exception.Message });
                }
                return(actionResult);
            }
            return(Json(new { success = false }));
        }
Пример #4
0
        public async Task <IActionResult> Index()
        {
            ViewBag.Current = "Tags";

            var tags = await _tagService.GetAll();

            var tagsVm = new List <TagsViewModel>();

            foreach (var tag in tags.OrderBy(o => o.TagName))
            {
                var coverImageUri = await _galleryService.GenerateGalleryUri(1, tag.TagName, "custominclusive", "include");

                var coverImageGallery = await _galleryService.Get(coverImageUri);

                var coverImage = coverImageGallery.GalleryItems.Single();
                var vm         = new TagsViewModel
                {
                    CategoryName        = tag.TagName,
                    CoverImageAppPath   = coverImage.AppPath,
                    CoverImageMediaType = coverImage.MediaType,
                    ItemCount           = tag.ItemCount,
                };

                tagsVm.Add(vm);
            }

            return(View(tagsVm));
        }
Пример #5
0
        public async Task <IActionResult> Get(string id, int itemIndexStart = 1, int numberOfItems = 48)
        {
            var galleryResponseList = await _galleryService.Get(id, itemIndexStart, numberOfItems);

            return(Ok(galleryResponseList));
        }
Пример #6
0
 public ActionResult AlbumIndex(int albumId)
 {
     return(View(_galleryService.Get(albumId)));
 }
Пример #7
0
        public ActionResult PostPrice(int productId, int attributeId)
        {
            var galleryImage = _galleryService.Get(x => x.PostId == productId && x.AttributeValueId == attributeId);

            return(galleryImage?.Price == null?Json("Liên hệ") : Json(galleryImage.Price));
        }