public async Task <IActionResult> PutStepperSchema(int id, QuestionnaireStoreModel stepperSchema) { if (id != stepperSchema.Id) { return(BadRequest()); } _context.Entry(stepperSchema).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StepperSchemaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public QuestionnaireStoreModel GetStoreModel() { var model = _questionnaireViewModel; // TODO: Check what the view model is and transform to the store model. QuestionnaireStoreModel schema = new QuestionnaireStoreModel(); schema.type = model.type; schema.fieldGroup = new List <QuestionGroup>(); foreach (QuestionGroupViewModel data in model.fieldGroup) { QuestionGroup questionGroup = new QuestionGroup(); questionGroup.fieldGroup = data.fieldGroup; questionGroup.hideExpression = data.hideExpression; questionGroup.templateOptions = data.templateOptions; questionGroup.expressionProperties = new List <ExpressionModel>(); if (data.expressionProperties != null) { foreach (var y in data.expressionProperties) { ExpressionModel epressionModel = new ExpressionModel(); epressionModel.Key = y.Key; epressionModel.Expression = y.Value; questionGroup.expressionProperties.Add(epressionModel); } } schema.fieldGroup.Add(questionGroup); } return(schema); }
public void SetUp() { _questionnaireStoreModel = createStoreModel(); _questionnaireViewModel = createViewModel(); _questionnaireWrapperWithStoreModel = new QuestionnaireWrapper(_questionnaireStoreModel); _questionnaireWrapperWithViewModel = new QuestionnaireWrapper(_questionnaireViewModel); }
public QuestionnaireStoreModel createStoreModel() { // QuestionnaireStoreModel QuestionnaireStoreModel model = new QuestionnaireStoreModel(); model.type = "type"; model.fieldGroup = new List <QuestionGroup>(); model.Id = 1; // QuestionGroup var questionGroup = new QuestionGroup(); questionGroup.fieldGroup = new List <Question>(); questionGroup.expressionProperties = new List <ExpressionModel>(); questionGroup.hideExpression = "hideExpressionCondition"; questionGroup.Id = 1; questionGroup.templateOptions.label = "questionGroup 1"; // ExpressionModel var expressionModel = new ExpressionModel(); expressionModel.Expression = "expression"; expressionModel.Key = "key"; // Question var questionModel = new Question(); questionModel.Id = 1; questionModel.key = "questionModelKey"; questionModel.templateOptions.Answer = "answer"; questionModel.templateOptions.Answer = "question"; questionModel.type = "inputfield"; questionModel.templateOptions.Id = 1; // Add to store model model.fieldGroup.Add(questionGroup); questionGroup.expressionProperties.Add(expressionModel); questionGroup.fieldGroup.Add(questionModel); return(model); }
public async Task <ActionResult <QuestionnaireViewModel> > GetStepperSchema(int id) { QuestionnaireStoreModel stepperSchema = await _context.JsonSchema .Include(j => j.fieldGroup).ThenInclude(j => j.templateOptions) .Include(j => j.fieldGroup).ThenInclude(j => j.fieldGroup).ThenInclude(j => j.templateOptions) .Include(j => j.fieldGroup).ThenInclude(j => j.fieldGroup).ThenInclude(j => j.templateOptions).ThenInclude(j => j.options) .Include(j => j.fieldGroup).ThenInclude(j => j.expressionProperties) .SingleOrDefaultAsync(x => x.Id == id); QuestionnaireViewModel schema = new QuestionnaireWrapper(stepperSchema).GetViewModel(); if (stepperSchema == null) { return(NotFound()); } return(schema); }
public QuestionnaireWrapper(QuestionnaireStoreModel questionnaireStoreModel) { this._questionnaireStoreModel = questionnaireStoreModel; }
public QuestionnaireWrapper(QuestionnaireViewModel questionnaireViewModel) { this._questionnaireStoreModel = new QuestionnaireWrapper(questionnaireViewModel).GetStoreModel(); }