public ActionResult ThemMonHocChoKhoa() { try { var model = new KhoaMonViewModel { Khoas = dbContext.Khoas.ToList(), MonHocs = dbContext.MonHocs.ToList() }; return(RedirectToAction("Index")); } catch { return(View()); } }
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()); } }