Exemplo n.º 1
0
        // GET: Titles
        public ActionResult Index()
        {
            //Titles titles = new Titles();
            var model = titleService.GetList();

            return(View(model));
        }
Exemplo n.º 2
0
        // 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));
        }