示例#1
0
        public IActionResult Create()
        {
            // Create the metadata info for the type
            SchemaFormInfo schemaFormInfo = _schemaFormBuilder.CreateSchemaForm(typeof(FullEmployeeVm));

            // Create a response which contains the metadata and an empty resource
            return(Json(new { schemaFormInfo.Form, schemaFormInfo.Schema, Data = new EditEmployeeVm() }));
        }
示例#2
0
        public IActionResult Edit(int id)
        {
            // Find the employee to the specified id
            FullEmployeeVm employeeVm = _employees.SingleOrDefault(e => e.Id == id);

            if (employeeVm == null)
            {
                // The employee could not be found
                return(HttpNotFound());
            }

            // Create the metadata info for the type
            SchemaFormInfo schemaFormInfo = _schemaFormBuilder.CreateSchemaForm(typeof(FullEmployeeVm));

            // Create a response which contains the metadata and the resource
            return(Json(new { schemaFormInfo.Form, schemaFormInfo.Schema, Data = employeeVm.ToEditEmployeeVm() }));
        }
示例#3
0
        public object PutCodeToCompile([FromBody] JToken input)
        {
            CompiledFormDto        result        = new CompiledFormDto();
            CompileResultContainer compileResult = null;

            if (input["csharpCode"] == null)
            {
                result.ErrorMessages.Add("No Code!");
                return(result);
            }

            try
            {
                compileResult = CompileService.TryCompileAndSearchType(input["csharpCode"].ToString());

                result.CompilationSuccessfull = compileResult.CompilationSuccessfull;
                result.TypeName      = compileResult.TypeName;
                result.ErrorMessages = compileResult.ErrorMessages;

                if (compileResult.CompilationSuccessfull)
                {
                    DefaultSchemaFormBuilder builder        = new DefaultSchemaFormBuilder();
                    SchemaFormInfo           schemaFormInfo = builder.CreateSchemaForm(compileResult.Type);
                    result.Form   = schemaFormInfo.Form;
                    result.Schema = schemaFormInfo.Schema;
                }
            }
            catch (Exception e)
            {
                result.ErrorMessages.Add(e.ToString());
            }
            finally
            {
                if (compileResult != null)
                {
                    compileResult.ReleaseResources();
                }
            }

            return(result);
        }