Exemple #1
0
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
        {
            if (actionExecutedContext.Response == null)
            {
                return;
            }

            var user = UmbracoContext.Current.Security.CurrentUser;

            if (user == null)
            {
                return;
            }

            if (actionExecutedContext.Response.Content is ObjectContent objectContent)
            {
                var model = objectContent.Value;

                if (model != null)
                {
                    var args = new EditorModelEventArgs(
                        model,
                        UmbracoContext.Current);
                    EditorModelEventManager.EmitEvent(actionExecutedContext, args);
                    objectContent.Value = args.Model;
                }
            }

            base.OnActionExecuted(actionExecutedContext);
        }
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
        {
            if (actionExecutedContext.Response == null)
            {
                return;
            }

            var user = UmbracoContext.Current.Security.CurrentUser;

            if (user == null)
            {
                return;
            }

            var objectContent = actionExecutedContext.Response.Content as ObjectContent;

            if (objectContent != null)
            {
                var model = objectContent.Value;

                if (model != null)
                {
                    EditorModelEventManager.EmitEvent(actionExecutedContext, new EditorModelEventArgs(
                                                          (dynamic)model,
                                                          UmbracoContext.Current));
                }
            }

            base.OnActionExecuted(actionExecutedContext);
        }
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
        {
            if (actionExecutedContext.Response == null)
            {
                return;
            }

            var user = Current.UmbracoContext.Security.CurrentUser;

            if (user == null)
            {
                return;
            }

            if (actionExecutedContext.Response.Content is ObjectContent objectContent)
            {
                var model = objectContent.Value;
                if (model != null)
                {
                    if (model is IDictionary modelDict)
                    {
                        foreach (var entity in modelDict)
                        {
                            if (entity is DictionaryEntry entry)
                            {
                                var args = CreateArgs(entry.Value);
                                EditorModelEventManager.EmitEvent(actionExecutedContext, args);
                                entry.Value = args.Model;
                            }
                        }
                    }
                    else
                    {
                        var args = CreateArgs(model);
                        EditorModelEventManager.EmitEvent(actionExecutedContext, args);
                        objectContent.Value = args.Model;
                    }
                }
            }

            base.OnActionExecuted(actionExecutedContext);
        }