Example #1
0
        public ActionResult Edit(string imageId, string albumId)
        {
            ImageView iv = new ImageView();

            iv.AlbumId = new Guid(albumId);
            if (Repo.IsAlbumSpecial(iv.AlbumId))
            {
                string userId      = User.Identity.GetUserId();
                var    userManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>();

                if (userManager.IsInRole(userId, "Admin"))
                {
                    iv.Image = Repo.SelectImageByID(new Guid(imageId));
                    return(PartialView(iv));
                }
                else
                {
                    ModelState.AddModelError("error", "Error: Only admin can edit this image.");
                    return(RedirectToAction("AjaxGetImage", new { albumId = albumId }));
                }
            }
            else
            {
                iv.Image = Repo.SelectImageByID(new Guid(imageId));
                return(PartialView(iv));
            }
        }
Example #2
0
        public ActionResult AjaxGetImage(Guid id)
        {
            Repo = GalleryRepositories.getRepo();
            Image img = Repo.SelectImageByID(id);

            var result = new {
                ImageId     = img.ImageId,
                FileName    = img.FileName,
                Title       = img.Title,
                Description = img.Description,
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }