示例#1
0
        public async Task <IActionResult> CreateSurvey([FromBody] Model.Input.Survey survey)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.ToString()));
            }

            var result = await _surveyService.CreateSurvey(survey);

            return(Ok(result));
        }
示例#2
0
        public async Task <Model.Output.Survey> CreateSurvey(Model.Input.Survey survey)
        {
            var newSurveyEntity = new Entity.Survey.Survey
            {
                Title           = survey.Title,
                Description     = survey.Description,
                StartDateTime   = survey.StartDateTime,
                EndDateTime     = survey.EndDateTime,
                CreatedDateTime = DateTime.Now
            };

            newSurveyEntity = await _repository.CreateSurvey(newSurveyEntity);

            return(await GetSurvey(newSurveyEntity.Id));
        }
示例#3
0
        public void CreateSurvey()
        {
            Assert.IsNotNull(surveyService);

            var surveyInputModel = new Model.Input.Survey
            {
                Title         = SurveyTitle,
                Description   = SurveyDescription,
                StartDateTime = SurveyStartDateTime,
                EndDateTime   = SurveyEndDateTime
            };

            var surveyOutputModel = surveyService.CreateSurvey(surveyInputModel).Result;

            Assert.IsNotNull(surveyOutputModel);
            Assert.IsTrue(surveyOutputModel.Id > 0);
            Assert.AreEqual(SurveyTitle, surveyOutputModel.Title);
            Assert.AreEqual(SurveyDescription, surveyOutputModel.Description);
            Assert.AreEqual(SurveyStartDateTime, surveyOutputModel.StartDateTime);
            Assert.AreEqual(SurveyEndDateTime, surveyOutputModel.EndDateTime);
        }