예제 #1
0
        public async Task <int> Transaction(SurveyViewModel surveyModel, char action)
        {
            try
            {
                var questions = surveyModel.SurveyQuestionsModel;
                var data      = Mapper.Map <Survey>(surveyModel);
                var result    = await _survey.Transaction(data, action);

                if (questions != null)
                {
                    foreach (var question in questions)
                    {
                        var dataQ = Mapper.Map <SurveyQuestions>(question);
                        await _survey.QuestionTransaction(dataQ, action);

                        var answers = question.SurveyAnswersModel;
                        if (answers != null)
                        {
                            foreach (var answer in answers)
                            {
                                var dataA = Mapper.Map <SurveyAnswers>(answer);
                                await _survey.AnswerTransaction(dataA, action);
                            }
                        }
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex.GetBaseException();
            }
        }