// GET: Elective/ElectiveSubject
        public ActionResult List()
        {
            var vm = new Models.ElectiveSubject.List();

            using (var db = new XkSystem.Models.DbContext())
            {
                var tb = (from p in db.Table <Course.Entity.tbSubject>()
                          join e in db.Table <Entity.tbElectiveSubject>()  on new { p.Id, ElectiveId = vm.ElectiveId } equals new { e.tbSubject.Id, ElectiveId = e.tbElective.Id } into subject
                          from s in subject.DefaultIfEmpty()
                          select new { p, s });
                if (!string.IsNullOrWhiteSpace(vm.SearchText))
                {
                    tb = tb.Where(p => p.s.tbSubject.SubjectName.Contains(vm.SearchText) || p.s.tbSubject.SubjectNameEn.Contains(vm.SearchText));
                }
                vm.ElectiveSubjectList = (from p in tb
                                          select new Dto.ElectiveSubject.List()
                {
                    Id = p.p.Id,
                    SubjectId = p.p.Id,
                    SubjectName = p.p.SubjectName,
                    IsOpen = p.s != null
                }).ToList();

                vm.ElectiveName = db.Table <Entity.tbElective>().FirstOrDefault(d => d.Id == vm.ElectiveId).ElectiveName;
            }
            return(View(vm));
        }
 public ActionResult List(Models.ElectiveSubject.List vm)
 {
     return(Code.MvcHelper.Post(returnUrl: Url.Action("List", new { SearchText = vm.SearchText, ElectiveId = vm.ElectiveId })));
 }