コード例 #1
0
        public async Task <SurveyedDto> Insert(SurveyedDto request)
        {
            var entity = AutoMapper.Mapper.Map <Surveyed>(request);

            entity.AnswerList   = null;
            entity.BranchOffice = branchOfficeRepository.Get(entity.BranchOffice.Id);

            entity.PersonSurveyed = await personSurveyedRepository.InsertAsync(entity.PersonSurveyed);

            entity = await entityRepository.InsertAsync(entity);

            entity.AnswerList = new List <Answer>();

            foreach (var answerDto in request.AnswerList)
            {
                var answer = AutoMapper.Mapper.Map <Answer>(answerDto);
                answer.Surveyed       = entity;
                answer.Question       = questionRepository.Get(answer.Question.Id);
                answer.QuestionOption = questionOptionRepository.Get(answer.QuestionOption.Id);
                answer.QuestionType   = questionTypeRepository.Get(answer.QuestionType.Id);

                answer = await answerRepository.InsertAsync(answer);

                entity.AnswerList.Add(answer);
            }

            return(AutoMapper.Mapper.Map <SurveyedDto>(entity));
        }
コード例 #2
0
        public async Task <bool> UpdateExistingOption(Guid id, IQuestionOption optionDto)
        {
            try
            {
                var option = await _optionRepository.Get(id);

                if (option == null)
                {
                    return(false);
                }
                Mappings.Mapper.Map <IQuestionOption, QuestionOption>(optionDto, option);

                await _optionRepository.Update(option);

                return(true);
            }
            catch (Exception e)
            {
                _logger.Error(e, "QuestionOptionManagementService.UpdateExistingOption");
                throw;
            }
        }