public async Task <ActionResult> ExportHDHocTapTraiNghiem(DateTime dateFrom, DateTime dateTo) { Account account = (Account)Session[Utils.Constant.MANAGER_SESSION]; if (account == null) { return(RedirectToRoute("login")); } using (var social = new HDHocTapTraiNghiemService()) { List <Registration> registrations = social.GetRegistrations(dateFrom, dateTo); string fileName = string.Concat("ds-hdhoctaptrainghiem.xlsx"); string filePath = System.Web.HttpContext.Current.Server.MapPath("~/Utils/Files/" + fileName); List <SubjectsRegisted> subjectsRegisteds = new List <SubjectsRegisted>(); foreach (var item in registrations) { using (var subjectRegistedService = new SubjectRegistedService()) { List <SubjectsRegisted> subjectsRegistedsTmp = subjectRegistedService.GetSubjectsRegistedsByRegistrationId(item.Id); foreach (var item01 in subjectsRegistedsTmp) { subjectsRegisteds.Add(item01); } } } await Utils.ExportExcel.GenerateXLSHoatDongHocTapTraiNghiem(registrations, subjectsRegisteds, dateFrom, dateTo, filePath); return(File(filePath, "application/vnd.ms-excel", fileName)); } }
public ActionResult GetSubjectRegistedByRegistrationId(int id) { using (var subjectRegistedService = new SubjectRegistedService()) { var subject = subjectRegistedService.GetSubjectsRegistedsByRegistrationId(id); var subjectJson = JsonConvert.SerializeObject(subject, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }); return(Json(new ReturnFormat(200, "success", subjectJson), JsonRequestBehavior.AllowGet)); } }