public ActionResult Index() { var school = (T_DM_Truong)Session[Constant.SCHOOL_SESSION]; if (school == null) { return(RedirectToRoute("login")); } using (var kHKTKhoaHocKiThuatRepository = new KHKTKhoaHocKiThuatService()) { List <KhoaHocKiThuatDetailDTO> hocKiThuatDetailDTOs = kHKTKhoaHocKiThuatRepository.GetKhoaHocKiThuatsBySchoolId(school.SchoolID); ViewBag.DSKHKT = hocKiThuatDetailDTOs; } return(View()); }
public async Task <ActionResult> DownloadFileByTruong() { var school = (T_DM_Truong)Session[Constant.SCHOOL_SESSION]; if (school == null) { return(RedirectToRoute("login")); } using (var kHKTKhoaHocKiThuatRepository = new KHKTKhoaHocKiThuatService()) { List <KhoaHocKiThuatDetailDTO> khoaHocKiThuatDetailDTOs = kHKTKhoaHocKiThuatRepository.GetKhoaHocKiThuatsBySchoolId(school.SchoolID); ViewBag.KHKT = khoaHocKiThuatDetailDTOs; string fileName = string.Concat("ds-khoahockythuat.xlsx"); string filePath = System.Web.HttpContext.Current.Server.MapPath("~/Utils/Files/" + fileName); await Utils.ExportExcel.GenerateXLSKhoaHocKiThuat(khoaHocKiThuatDetailDTOs, filePath); return(File(filePath, "application/vnd.ms-excel", fileName)); } }