public ActionResult Save(EditableImage image)
        {
            if (!EditableImageAuthorization.Authorization())
            {
                throw new Exception("Bu işlemi yapmak için yetkiniz yok.");
            }

            EditableImage existsImage = UnigateObject.Query("EditableImage")
                                        .WhereEqualTo("Code", image.Code)
                                        .FirstOrDefault <EditableImage>();

            Guid imageGuid = Guid.Empty;

            if (existsImage != null)
            {
                var update = UnigateObject.Update("EditableImage")
                             .Column("Code", image.Code)
                             .Column("ImageFile", image.ImageFile)
                             .WhereEqualTo("ContentId", existsImage.ContentId)
                             .Execute();

                if (update.ResultCode == ResultCode.Successfull)
                {
                    imageGuid = existsImage.ContentId;
                }
            }
            else
            {
                var insert = UnigateObject.Insert("EditableImage", image).Execute();
                if (insert.ResultCode == ResultCode.Successfull)
                {
                    imageGuid = Guid.Parse(insert.OutParameters.Get("ContentId"));
                }
            }

            return(new JsonResult()
            {
                Data = imageGuid,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
コード例 #2
0
        public static string EditableImage(this HtmlHelper helper, string fileCode, string cssclass = null)
        {
            var auth = EditableImageAuthorization.Authorization();

            EditableImage file = UnigateObject.Query("EditableImage")
                                 .WhereEqualTo("Code", fileCode).FirstOrDefault <EditableImage>();

            if (file == null)
            {
                file           = new EditableImage();
                file.ImageFile = "/Modules/Plugins/Unigate.Plugins.EditableImage/Assets/Images/noimage.png";
                file.ContentId = new Guid();
            }

            var image = "<img id=\"" + file.ContentId + "\" class=\"" + cssclass + "\" src=\"" + file.ImageFile + "\" />";

            if (auth)
            {
                string pencil = "<img class=\"filebrowser pencil\" data-code=\"" + fileCode + "\" src=\"/Modules/Plugins/Unigate.Plugins.EditableImage/Assets/Images/pencil.png\">";
                return("<span class=\"editable-imageholder\">" + pencil + image + "</span>");
            }

            return(image);
        }