public ActionResult Create(string models) { try { var namhocs = JsonConvert.DeserializeObject <IEnumerable <NamHoc> >(models); if (namhocs != null) { foreach (NamHoc namhoc in namhocs) { _NamHocService.Insert(namhoc); foreach (HocKy hocKy in _HocKyService.GetAll()) { HocKyNamHoc hocKyNamHoc = new HocKyNamHoc(); hocKyNamHoc.MaHocKy = hocKy.MaHocKy; hocKyNamHoc.MaNamHoc = namhoc.MaNamHoc; _HocKyNamHocService.Insert(hocKyNamHoc); } } } return(Json(namhocs)); } catch (Exception e) { return(Json(new { error = e.Message })); } }
/// <summary> /// return view ThoiKhoaBieu /// </summary> /// <returns>ThoiKhoaBieu.cshtml</returns> public ActionResult LapThoiKhoaBieu() { ViewBag.dsTKB = JsonConvert.SerializeObject(_ThoiKhoaBieuService.GetAll()); ViewBag.dsNamHoc = JsonConvert.SerializeObject(_NamHocService.GetAll()); ViewBag.dsHocKy = JsonConvert.SerializeObject(_HocKyService.GetAll()); ViewBag.dsGiaoVien = JsonConvert.SerializeObject(_GiaoVienService.GetAllGiaoVien()); ViewBag.dsMonHoc = JsonConvert.SerializeObject(_MonHocService.GetAll() .Select(e => new { value = e.MaMonHoc, text = e.TenMonHoc })); //ViewBag.dsLopHoc = JsonConvert.SerializeObject(_LopHocService.GetAll()); return(View()); }
// // GET: /BangDiem/ public ActionResult BangDiemMonHoc() { List <MonHocOfKhoiLop> monHocKhoiLop = new List <MonHocOfKhoiLop>(); foreach (MonHoc monHoc in _MonHocService.GetAllWithChild()) { foreach (KhoiLop khoiLop in monHoc.dsKhoi) { monHocKhoiLop.Add(new MonHocOfKhoiLop { MaMonHoc = monHoc.MaMonHoc, TenMonHoc = monHoc.TenMonHoc, MaKhoi = khoiLop.MaKhoi }); } } ViewBag.listNamHoc = _NamHocService.GetAll().Select(m => new { value = m.MaNamHoc, text = m.NamBatDau + " - " + m.NamKetThuc }); ViewBag.listHocKy = _HocKyService.GetAll().Select(m => new { value = m.MaHocKy, text = m.TenHocKy }); ViewBag.listKhoiLop = JsonConvert.SerializeObject(_KhoiLopService.GetAll().Select(m => new { value = m.MaKhoi, text = m.TenKhoi })); ViewBag.listLopHoc = JsonConvert.SerializeObject(_LopHocService.GetAll().OrderBy(m => m.TenLop).Select(m => new { value = m.MaLopHoc, text = m.TenLop, MaNamHoc = m.MaNamHoc, MaKhoi = m.MaKhoi })); ViewBag.listMonHoc = JsonConvert.SerializeObject(monHocKhoiLop.Select(m => new { value = m.MaMonHoc, text = m.TenMonHoc, MaKhoi = m.MaKhoi })); return(View()); }