private void InitializeModel(TemplateModel model) { LoadFormIfAvailable(model); if (ModelState.ContainsKey("Source.ItemSeparator")) { model.Source.ItemSeparator = ModelState["Source.ItemSeparator"].RawValue.ToString(); } model.SourceTypeList = new List <SelectListItem> { new() { Value = "Csv", Text = "Csv" }, new() { Value = "JsonArray", Text = "Json Array" }, new() { Value = "JsonObject", Text = "Json Object" } }; LoadAvailableForms(model); if (model.Source.ItemSeparator == null) { model.Source.ItemSeparator = Environment.NewLine; } if (string.IsNullOrEmpty(model.Source.Template)) { return; } _microTemplateProcessor.ExecuteTemplate(model.Source); }
public IActionResult GetTemplate([FromQuery] IDictionary <string, string> templateParams) { if (!ModelState.IsValid) { return(BadRequest()); } try { var model = MicroTemplateInfo.FromDictionary(templateParams); model.SetDefaultsForNulls(); _microTemplateProcessor.ExecuteTemplate(model); return(Ok(model)); } catch (Exception ex) { return(Problem(UtilString.GetStringException(ex))); } }