コード例 #1
0
        public ActionResult <SurveyOut> GetSyrvey(Guid surveyId)
        {
            try
            {
                var customerId = GetCurrentCustomerId();
                surveyId = new Guid(surveyId.ToString().Trim());

                if (surveyId.ToString() == string.Empty)
                {
                    return(BadRequest());
                }

                var survey = _surveyRepository.GetSurveyById(customerId, surveyId);

                if (survey == null)
                {
                    return(NotFound());
                }

                var syrveyOut = SurveyMapper.MapSurvey(survey);
                return(syrveyOut);
            }
            catch (Exception)
            {
                return(StatusCode(500));
            }
        }
コード例 #2
0
        public ActionResult CreateSurvey([FromBody] CreateSurvey createSurvey)
        {
            //if (!ModelState.IsValid)
            //    return BadRequest();

            try
            {
                var survey = SurveyMapper.MapSurvey(createSurvey);
                _surveyRepository.CreateSurvey(survey);
                return(StatusCode(201));
            }
            catch (Exception)
            {
                return(StatusCode(500));
            }
        }