Exemplo n.º 1
0
        public async Task <ActionResult> Create(SurveyModel survey)
        {
            var surveyDto = _mapper.Map <Survey>(survey);
            await _surveyManager.Create(surveyDto);

            return(Ok());
        }
Exemplo n.º 2
0
        public async Task GivenSurvey_WhenCreate_ThenCreateSuccessful()
        {
            //?Given
            var survey = GetSurvey();

            //?When
            await _surveyManager.Create(survey);

            //?Then
            _mockRepository.Verify(t => t.Create(It.Is <Survey>(e => MessageeIsWellCreated(e, survey))), Times.Once);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([FromBody] Surveys inputModel)
        {
            try
            {
                inputModel.CreatedDate = DateTime.Now;
                var data = await _surveysManager.Create(inputModel);

                if (inputModel.Questions != null)
                {
                    await CreateQuestion(inputModel);
                }
                return(Ok(data));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }