public async Task <ActionResult <FormlySchemaWithAnswers> > GetFormlySchemaWithAnswers(int id) { FormlySchemaWithAnswers formlySchemaWithAnswers = await _context.FormlySchemaWithAnswers .Include(j => j.Schema).ThenInclude(s => s.TemplateOptions) .Include(j => j.Schema).ThenInclude(s => s.TemplateOptions).ThenInclude(g => g.Options) .Include(j => j.Schema).ThenInclude(s => s.Validation).ThenInclude(w => w.Messages) .Include(j => j.Schema).ThenInclude(s => s.FieldGroup).ThenInclude(k => k.DefaultValue) .Include(j => j.Schema).ThenInclude(s => s.FieldGroup).ThenInclude(k => k.TemplateOptions).ThenInclude(z => z.Options) .Include(j => j.Schema).ThenInclude(s => s.FieldGroup).ThenInclude(k => k.FieldArray).ThenInclude(z => z.FieldGroup).ThenInclude(t => t.TemplateOptions).ThenInclude(g => g.Options) .Include(j => j.Schema).ThenInclude(s => s.FieldGroup).ThenInclude(k => k.FieldArray).ThenInclude(z => z.FieldGroup).ThenInclude(t => t.Validation).ThenInclude(s => s.Messages) .Include(j => j.Response).ThenInclude(s => s.Children) .SingleAsync(j => j.Id == id); if (formlySchemaWithAnswers == null) { return(NotFound()); } foreach (ChildFormlySchema x in formlySchemaWithAnswers.Schema) { if (x.FieldGroup.Count == 0) { x.FieldGroup = null; } } return(formlySchemaWithAnswers); }
public async Task <IActionResult> PutFormlySchemaWithAnswers(int id, FormlySchemaWithAnswers formlySchemaWithAnswers) { if (id != formlySchemaWithAnswers.Id) { return(BadRequest()); } _context.Entry(formlySchemaWithAnswers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FormlySchemaWithAnswersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <FormlySchemaWithAnswers> > PostFormlySchemaWithAnswers(FormlySchemaWithAnswers formlySchemaWithAnswers) { _context.FormlySchemaWithAnswers.Add(formlySchemaWithAnswers); await _context.SaveChangesAsync(); return(CreatedAtAction("GetFormlySchemaWithAnswers", new { id = formlySchemaWithAnswers.Id }, formlySchemaWithAnswers)); }