// GET: Doctors public ActionResult Index(DoctorIndexViewModel doctorIndexViewModel) {//hem doktorlar hem de title'ları listelenecek: var query = doctorService.GetQuery(); var titles = titleService.GetList().Select(e => new SelectListItem() {//aşağıda db.Titles yazmak yerine burda servisten çekilp value ve text değeri bulunurak yapıldı.Garanti yol. Value = e.Id.ToString(), Text = e.Title }); if (doctorIndexViewModel.TitleId != 0) { //search için yaptık burayı dolayısıyla GetQuery de search için oluşturuldu. query = query.Where(e => e.TitleId == doctorIndexViewModel.TitleId); //title'a uyan doktor getirilir. } doctorIndexViewModel.Doctors = query.ToList(); //koşula uyan doktor doctors listesine atıldı.Listeleme için. doctorIndexViewModel.Titles = new SelectList(titles, "Value", "Text", doctorIndexViewModel.TitleId); return(View(doctorIndexViewModel)); }
public async Task <IActionResult> DoctorIndex(bool isApproval) { var doctor = await _doctorRepository.GetDoctorByUserEmail(this.User.Identity.Name); if (doctor == null) { return(NotFound()); } var model = new DoctorIndexViewModel { IsApproval = isApproval }; if (model.IsApproval) { model.ModelList = (await _appointmentRepository.GetNotAprovedDoctor(doctor.Id)) .Select(a => new IndexViewModel { Id = a.Id, Start = a.Start, AnimalName = a.Animal.Name, DoctorName = a.Doctor.User.FullName, End = a.End, IsAproved = a.IsAproved }).OrderByDescending(a => a.Start).ToList(); } else { model.ModelList = (await _appointmentRepository.GetAllDoctor(doctor.Id)) .Select(a => new IndexViewModel { Id = a.Id, Start = a.Start, AnimalName = a.Animal.Name, DoctorName = a.Doctor.User.FullName, End = a.End, IsAproved = a.IsAproved }).OrderByDescending(a => a.Start).ToList(); } return(View(model)); }