public async Task <TestTemplateModel> Create(TestTemplateModel model) { var testTemplate = new TestTemplate { ExecuteTime = new TimeSpan(0, 10, 0), Name = model.Name, CountOfQuestions = model.CountOfQuestions, Description = model.Description, CreatedAt = model.CreatedAt, IsActive = true, Questions = model.Questions .Select(x => new QuestionTemplate { Name = x.Name, ControlType = x.ControlType, Answers = x.Answers.Select(f => new AnswerTemplate { Answer = f.Answer, IsCorrect = f.IsCorrect }).ToList() }).ToList() }; testTemplateRepository.Add(testTemplate); await dataContext.SaveChangesAsync(); return(TestTemplateMap.Map(testTemplate)); }
public async Task <ActionResult <TestTemplateModel> > Create(TestTemplateModel model) { var testTemplate = await testTemplatesService.Create(model); return(Ok(testTemplate)); }