Example #1
0
        public async Task <IEnumerable <SurveyDto> > GetSurveys()
        {
            var surveys = await _surveyRepository.GetAllAsync();

            var questionOrders = await _questionOrderRepository.GetAllAsync();

            var surveysDto        = _mapper.Map <IEnumerable <SurveyDto> >(surveys);
            var questionOrdersDto = _mapper.Map <IEnumerable <QuestionOrderDto> >(questionOrders);

            surveysDto
            .ToList()
            .ForEach(s => s.QuestionOrders = questionOrdersDto
                                             .Where(q => q.SurveyId.Equals(s.Id.Value)));

            return(_mapper.Map <IEnumerable <SurveyDto> >(surveys));
        }