public async Task <IActionResult> CreateVisit() { var allDoctors = await _doctorsRepository.GetAllDoctors(); var selectList = new List <SelectListItem>(); foreach (var doctor in allDoctors) { var specname = await _specializationsRepository.GetSpecializationById(doctor.SpecializationId); selectList.Add(new SelectListItem { Value = doctor.Name, Text = $"{specname.Name} - {doctor.FirstName} {doctor.LastName}" }); } var orderedDoctors = selectList.OrderBy(m => m.Text).ToList(); var visitModel = new CreateVisitViewModel { Doctors = orderedDoctors, StartDateTime = DateTime.Today }; return(View(visitModel)); }
public async Task <Specialization> GetSpecializationById(int id) { return(await _specializationsRepo.GetSpecializationById(id)); }