예제 #1
0
        public ActionResult ThemMonHocChoKhoa()
        {
            try
            {
                var model = new KhoaMonViewModel
                {
                    Khoas   = dbContext.Khoas.ToList(),
                    MonHocs = dbContext.MonHocs.ToList()
                };

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
예제 #2
0
        public ActionResult ThemMonHocChoKhoa(KhoaMonViewModel model)
        {
            try
            {
                var khoaMon = new KhoaMon
                {
                    KhoaId        = model.Khoa,
                    MonHocId      = model.MonHoc,
                    TinChi        = model.TinChi,
                    TongSoTietHoc = model.TongSoTietHoc
                };

                dbContext.KhoaMons.Add(khoaMon);
                dbContext.SaveChanges();

                return(RedirectToAction("ThemMonHocChoKhoa"));
            }
            catch
            {
                return(View());
            }
        }