Пример #1
0
        public DentistInfoForDetailsVM GetDentistDetails(int dentistId)
        {
            var dentist = _mapper.Map <DentistVM>(_dentistRepository.GetById(dentistId));
            var visits  = _visitRepository.GetForDentist(dentistId).OrderBy(v => v.VisitDate.Date).ThenBy(v => v.VisitDate.TimeOfDay).ProjectTo <VisitInfoForDentistDetailsVM>(_mapper.ConfigurationProvider).ToList();

            foreach (var visit in visits)
            {
                visit.Patient = _mapper.Map <PatientBasicInfoVM>(_patientRepository.GetById(visit.PatientId));
            }

            return(new DentistInfoForDetailsVM
            {
                Dentist = dentist,
                Visits = visits
            });
        }