public async Task <IActionResult> Post([FromBody] FormInputModel formInputModel)
        {
            await _dbContext.Forms.AddAsync(Form.Create(formInputModel.Name, formInputModel.Description));

            await _dbContext.SaveChangesAsync();

            return(NoContent());
        }
Example #2
0
        public async Task <IActionResult> Post([FromBody] SectionInputModel sectionInputModel)
        {
            var section = Section.Create(sectionInputModel.Name,
                                         sectionInputModel.Description,
                                         sectionInputModel.FormId);
            await _dbContext.Sections.AddAsync(section);

            await _dbContext.SaveChangesAsync();

            return(NoContent());
        }
        public async Task Post([FromBody] UserInputModel userInputModel)
        {
            var user = Domain.Users.User.Create(userInputModel.Email,
                                                userInputModel.Password,
                                                userInputModel.FirstName,
                                                userInputModel.LastName);

            foreach (var form in userInputModel.Forms)
            {
                user.AddForm(form);
            }

            await _dbContext.Users.AddAsync(user);

            await _dbContext.SaveChangesAsync();
        }
        public async Task <IActionResult> Post([FromBody] IEnumerable <QusetionInputModel> questionInputModelList)
        {
            // TODO: Add strategy here
            foreach (var questionInputModel in questionInputModelList)
            {
                await _dbContext.Questions.AddAsync(_questionStrategy.GetQuestionType(questionInputModel.Type)
                                                    .Create(questionInputModel.SectionId,
                                                            questionInputModel.Text,
                                                            questionInputModel.Description,
                                                            questionInputModel.IsRequired,
                                                            questionInputModel.CustomErrorMessage,
                                                            false,
                                                            questionInputModel.Answers.Select(x => x.Name)));
            }

            await _dbContext.SaveChangesAsync();

            return(NoContent());
        }