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)); }
public int Add(Question item) { if (string.IsNullOrEmpty(item.Text)) { return(0); } if (item.Text.Count() > 300) { return(0); } var questionType = _qtrepository.Get(item.QuestionTypeId); if (questionType == null) { return(0); } int id = _repository.Add(item); return(id); }
public QuestionType Get(int id) { return(_repository.Get(id)); }