Exemple #1
0
        public JsonResult EditImageInfo(FormCollection formValues)
        {
            GalleryRepository rep   = this.GetGalleryRepository();
            PGImage           image = rep.GetImageFromVPath(formValues["ImageVPathEditImageInfo"]);

            if (image == null)
            {
                Response.StatusCode = 400;
                return(Json(new { error = "Image not found at " + formValues["ImageVPath"] }));
            }

            image.FriendlyName = formValues["ImageFriendlyName"];
            image.ImageDescr   = formValues["ImageDescription"];

            if (!ValidName(image.FriendlyName) || !ValidName(image.ImageDescr))
            {
                Response.StatusCode = 400;
                return(Json(new { error = "Image not found at " + formValues["ImageVPath"] }));
            }

            rep.UpdateImageInfo(image);

            return(Json(new { ImageFriendlyName = image.FriendlyName, ImageDescr = image.ImageDescr }, JsonRequestBehavior.AllowGet));
        }