Пример #1
0
        // GET: Teachers
        //public ActionResult Index()
        //{
        //    return View(db.Teacheres.ToList());
        //}

        public ActionResult Index(int?id, int?TeacherID)
        {
            var viewModel = new CenterIndexData();

            viewModel.Teachers = db.Teacheres
                                 .Include(i => i.Students)
                                 .OrderBy(i => i.firstname);



            //if (id != null)
            //{
            //    ViewBag.TeacherID = id.Value;
            //    viewModel.Teachers = viewModel.Students.Where(
            //        i => i.id == id.Value).Single().;
            //}

            if (id != null)
            {
                viewModel.Teachers = db.Teacheres
                                     .Include(i => i.Students)
                                     .OrderBy(i => i.firstname);

                ViewBag.TeacherID  = id.Value;
                viewModel.Students = viewModel.Teachers.Where(
                    x => x.id == id.Value).Single().Students;
            }

            return(View(viewModel));
        }
Пример #2
0
        public ActionResult Index(int?id, int?TeacherID)
        {
            var viewModel = new CenterIndexData();

            viewModel.Centers = db.Centeres
                                .Include(i => i.Teachers)
                                .OrderBy(i => i.name);



            if (id != null)
            {
                ViewBag.centerId   = id.Value;
                viewModel.Teachers = viewModel.Centers.Where(
                    i => i.id == id.Value).Single().Teachers;
            }

            if (TeacherID != null)
            {
                viewModel.Teachers = db.Teacheres
                                     .Include(i => i.Students)
                                     .OrderBy(i => i.firstname);

                ViewBag.TeacherID  = TeacherID.Value;
                viewModel.Students = viewModel.Teachers.Where(
                    x => x.id == TeacherID.Value).Single().Students;
            }

            return(View(viewModel));
        }