public ActionResult DangKyMonHoc()
        {
            string           maSV       = Session["MaSV"].ToString().Trim();
            KhoaBLL          contextK   = new KhoaBLL();
            LopTinChiBLL     contextLTC = new LopTinChiBLL();
            List <LopTinChi> lstLTC     = contextLTC.GetAll();

            MonHocBLL    contextMH = new MonHocBLL();
            GiangVienBLL contextGV = new GiangVienBLL();
            //  chỉ cho sinh viên đăng ký lớp đang mở
            List <LopTinChiModel> listLTCModel = new List <LopTinChiModel>();

            foreach (LopTinChi ltc in lstLTC)
            {
                var query = ltc.SinhViens.Where(x => x.MaSV == maSV).FirstOrDefault();
                if (query == null)
                {
                    if (ltc.TrangThai == true && ltc.SinhViens.Count < 50)
                    {
                        GiangVien      giangVien = contextGV.GetById(ltc.MaGV);
                        MonHoc         monHoc    = contextMH.GetById(ltc.MaMonHoc);
                        LopTinChiModel ltcModel  = new LopTinChiModel()
                        {
                            MaLopTC        = ltc.MaLopTC,
                            TrangThai      = ltc.TrangThai,
                            MaGV           = ltc.MaGV,
                            MaMonHoc       = ltc.MaMonHoc,
                            Nhom           = ltc.Nhom,
                            NienKhoa       = ltc.NienKhoa,
                            GiangVienModel = new GiangVienModel()
                            {
                                MaGV       = giangVien.MaGV,
                                Email      = giangVien.Email,
                                GioiTinh   = giangVien.GioiTinh,
                                HoVaTenLot = giangVien.HoVaTenLot,
                                MaKhoa     = giangVien.MaKhoa,
                                MatKhau    = giangVien.MatKhau,
                                NgaySinh   = giangVien.NgaySinh,
                                SDT        = giangVien.SDT,
                                TenGV      = giangVien.TenGV,
                                TrinhDo    = giangVien.TrinhDo
                            },
                            MonHoc = new MonHocModel
                            {
                                MaMH             = monHoc.MaMH,
                                SoTinChiLyThuyet = monHoc.SoTinChiLyThuyet,
                                SoTinChiThucHanh = monHoc.SoTinChiThucHanh,
                                TenMH            = monHoc.TenMH
                            }
                        };
                        listLTCModel.Add(ltcModel);
                    }
                }
            }
            ViewBag.Khoa = new SelectList(contextK.GetAll(), "MaKhoa", "TenKhoa");
            return(View(listLTCModel));
        }
 // GET: Admin/GiangViens/Create
 //[SessionCheck]
 public ActionResult Create()
 {
     ViewBag.MaKhoa = new SelectList(contextKhoa.GetAll(), "MaKhoa", "TenKhoa");
     return(View());
 }
        public JsonResult LocTheoNieKhoaHocKy(string nienKhoa, int hocky)
        {
            string maSV = Session["MaSV"].ToString().Trim();

            if (string.IsNullOrEmpty(nienKhoa) || hocky < 0 || hocky > 3)
            {
                return(Json(new { msg = "FALSE" }));
            }
            KhoaBLL          contextK   = new KhoaBLL();
            LopTinChiBLL     contextLTC = new LopTinChiBLL();
            List <LopTinChi> lstLTC     = contextLTC.GetAll();

            NienKhoaHocKyBLL      contextNKHK  = new NienKhoaHocKyBLL();
            MonHocBLL             contextMH    = new MonHocBLL();
            GiangVienBLL          contextGV    = new GiangVienBLL();
            List <LopTinChiModel> listLTCModel = new List <LopTinChiModel>();

            foreach (LopTinChi ltc in lstLTC)
            {
                NienKhoaHocKy nkhk  = contextNKHK.GetById(ltc.NienKhoa);
                var           query = ltc.SinhViens.Where(x => x.MaSV == maSV).FirstOrDefault();
                if (query == null)
                {
                    if (ltc.TrangThai == true && ltc.NienKhoa == nienKhoa && nkhk.HocKy == hocky && ltc.SinhViens.Count < 50)
                    {
                        GiangVien      giangVien = contextGV.GetById(ltc.MaGV);
                        MonHoc         monHoc    = contextMH.GetById(ltc.MaMonHoc);
                        LopTinChiModel ltcModel  = new LopTinChiModel()
                        {
                            MaLopTC        = ltc.MaLopTC,
                            TrangThai      = ltc.TrangThai,
                            MaGV           = ltc.MaGV,
                            MaMonHoc       = ltc.MaMonHoc,
                            Nhom           = ltc.Nhom,
                            NienKhoa       = ltc.NienKhoa,
                            GiangVienModel = new GiangVienModel()
                            {
                                MaGV       = giangVien.MaGV,
                                Email      = giangVien.Email,
                                GioiTinh   = giangVien.GioiTinh,
                                HoVaTenLot = giangVien.HoVaTenLot,
                                MaKhoa     = giangVien.MaKhoa,
                                MatKhau    = giangVien.MatKhau,
                                NgaySinh   = giangVien.NgaySinh,
                                SDT        = giangVien.SDT,
                                TenGV      = giangVien.TenGV,
                                TrinhDo    = giangVien.TrinhDo
                            },
                            MonHoc = new MonHocModel
                            {
                                MaMH             = monHoc.MaMH,
                                SoTinChiLyThuyet = monHoc.SoTinChiLyThuyet,
                                SoTinChiThucHanh = monHoc.SoTinChiThucHanh,
                                TenMH            = monHoc.TenMH
                            }
                        };
                        listLTCModel.Add(ltcModel);
                    }
                }
            }

            ViewBag.Khoa = new SelectList(contextK.GetAll(), "MaKhoa", "TenKhoa");
            if (listLTCModel.Count > 0)
            {
                return(Json(new { msg = listLTCModel }));
            }
            return(Json(new { msg = "FALSE" }));
        }
 public ActionResult Index()
 {
     return(View(context.GetAll()));
 }