Exemplo n.º 1
0
        public ActionResult Courses()
        {
            CoursesVM model = new CoursesVM();

            using (var ctx = new CSEntities())
            {
                // Drop Down List For Teachers
                model.TeacherList = (from t in ctx.Teachers select t).ToList();
                List <SelectListItem> itemsT = new List <SelectListItem>();
                foreach (var item in model.TeacherList)
                {
                    itemsT.Add(new SelectListItem {
                        Value = item.ID.ToString(), Text = item.Person.FName + " " + item.Person.LName
                    });
                }
                model.ValuesT = itemsT;

                // Drop Down List For Courses
                model.CoursesList = (from c in ctx.CoursesLists select c).ToList();
                List <SelectListItem> itemsC = new List <SelectListItem>();
                foreach (var item in model.CoursesList)
                {
                    itemsC.Add(new SelectListItem {
                        Value = item.ID.ToString(), Text = item.Name
                    });
                }
                model.ValuesC = itemsC;

                //List of Courses
                // model.CoursesUser = ctx.Courses1(Convert.ToInt32(Session["ID"])).ToList();
                model.CoursesUser = ctx.CoursesForAll(Convert.ToInt32(Session["ID"])).ToList();
            }
            return(View(model));
        }