public async Task <ActionResult <Logic.Objects.Option> > PostSurveyOption([FromBody, Bind("")] ApiSurveyOption newSurveyOption)
        {
            try
            {
                Logic.Objects.Option logicOption = new Logic.Objects.Option()
                {
                    surveyOptionID    = Guid.NewGuid(),
                    displayText       = newSurveyOption.displayText,
                    surveyOptionValue = newSurveyOption.surveyOptionValue
                };
                try
                {
                    await repository.CreateSurveyOptionAsync(logicOption);

                    await repository.SaveAsync();

                    return(Ok(await repository.GetSurveyOptionByIDAsync(logicOption.surveyOptionID)));
                }
                catch (Exception e)
                {
                    throw e.InnerException;
                }
            }
            catch (Exception e)
            {
                throw e.InnerException;
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <Logic.Objects.Option> > PostSurveyQuestionOption(Guid surveyQuestionID, [FromBody, Bind("surveyOptionID, displayText, surveyOptionValue")] ApiSurveyOption questionOption)
        {
            try
            {
                Logic.Objects.Option logicSurveyOption = new Logic.Objects.Option()
                {
                    surveyOptionID    = Guid.NewGuid(),
                    displayText       = questionOption.displayText,
                    surveyOptionValue = questionOption.surveyOptionValue,
                };
                try
                {
                    await repository.CreateSurveyOptionAsync(logicSurveyOption);

                    await repository.SaveAsync();

                    await repository.CreateSurveyQuestionOptionXrefAsync(logicSurveyOption, surveyQuestionID, questionOption.isActive, questionOption.sortOrder);

                    await repository.SaveAsync();

                    return(Ok(logicSurveyOption));
                }
                catch (Exception e)
                {
                    return(BadRequest(e.Message));
                }
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
        }