예제 #1
0
        public HttpResponseMessage <JsonQueryResult> Get(
            [FromUri(Name = "designmode")] bool isInDesignMode = false,
            string id    = null,
            string ns    = null,
            string alias = null
            )
        {
            using (Profiler.Measure("FormController.Get"))
            {
                // Get the entityRef
                EntityRef formRef = WebApiHelpers.MakeEntityRef(id, ns, alias);

                long formId;

                try
                {
                    formId = formRef.Id;
                } catch (ArgumentException)
                {
                    throw new FormNotFoundException();
                }

                EntityData formEntityData = _formControllerRequestHandler.GetFormAsEntityData(formId, isInDesignMode);

                var context = new EntityPackage();
                context.AddEntityData(formEntityData, "formEntity");
                return(new HttpResponseMessage <JsonQueryResult>(context.GetQueryResult()));
            }
        }
예제 #2
0
        /// <summary>
        ///     Given a type, get the generated form for it.
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="isInDesignMode">if set to <c>true</c> [is in design mode].</param>
        /// <returns>
        ///     A response containing entity data for the form
        /// </returns>
        public static HttpResponseMessage <JsonQueryResult> GetGeneratedFormForType(EntityRef entityType, bool isInDesignMode)
        {
            EntityData formEntityData = EditFormHelper.GenerateDefaultFormForResourceType(entityType, isInDesignMode);

            var entityBatch = new EntityPackage( );

            entityBatch.AddEntityData(formEntityData, "formEntity");

            return(new HttpResponseMessage <JsonQueryResult>(entityBatch.GetQueryResult( )));
        }
예제 #3
0
        public HttpResponseMessage <JsonQueryResult> GetNavigationTree()
        {
            EntityPackage context;

            context = new EntityPackage();
            EntityData tree = ConsoleTreeRepository.GetTree();

            context.AddEntityData(tree, "navItems");
            return(new HttpResponseMessage <JsonQueryResult>(context.GetQueryResult()));
        }
        /// <summary>
        ///     Packages the form data response.
        /// </summary>
        /// <param name="entityData">The entity data.</param>
        /// <param name="initiallyHiddenControls">The initially hidden controls.</param>
        /// <returns></returns>
        private FormDataResponse PackageFormDataResponse(EntityData entityData, ISet <long> initiallyHiddenControls)
        {
            var context = new EntityPackage();

            context.AddEntityData(entityData, "entity");

            var response = new FormDataResponse
            {
                FormDataEntity          = context.GetQueryResult(),
                InitiallyHiddenControls = initiallyHiddenControls
            };

            return(response);
        }
예제 #5
0
        /// <summary>
        ///     Given a type, get the default form for it.
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="isInDesignMode">if set to <c>true</c> [is in design mode].</param>
        /// <param name="forceGenerate">Force a generated form to be used</param>
        /// <returns>
        ///     A response containing entity data for the form
        /// </returns>
        public static HttpResponseMessage <JsonQueryResult> GetDefaultFormForType(EntityType entityType, bool isInDesignMode, bool forceGenerate)
        {
            CustomEditForm formRef = entityType.DefaultEditForm;

            if (formRef != null && !forceGenerate)
            {
                var entityBatch = new EntityPackage( );

                EntityData formEntityData = EditFormHelper.GetFormAsEntityData(formRef);

                entityBatch.AddEntityData(formEntityData, "formEntity");

                return(new HttpResponseMessage <JsonQueryResult>(entityBatch.GetQueryResult( )));
            }
            //TODO: return something to indicate that there is no form
            return(GetGeneratedFormForType(entityType, isInDesignMode));
        }