public async Task <ActionResult> ExportExcel(int id) { Account usersession = (Account)Session[CommonConstants.USER_SESSION]; if (usersession == null || usersession.RoleId != 2) { Session.RemoveAll(); return(RedirectToRoute("login", null)); } if (id == 2) { List <RegistrationInterview> registrationInterviews = registrationInterviewRepository.GetRegistrationInterviewsByManagementUnitIdCompleted(usersession.ManagementUnitId); string fileName = string.Concat("ds-hoanthanh.xlsx"); string filePath = System.Web.HttpContext.Current.Server.MapPath("~/Utils/Excel/" + fileName); await Utils.ExportExcel.GenerateXLSRegistrationCompleted(registrationInterviews, filePath); return(File(filePath, "application/vnd.ms-excel", fileName)); } else if (id == 3) { List <RegistrationInterview> registrationInterviews = registrationInterviewRepository.GetRegistrationInterviewsByManagementUnitIdInProcess(usersession.ManagementUnitId); string fileName = string.Concat("ds-chuahoanthanh.xlsx"); string filePath = System.Web.HttpContext.Current.Server.MapPath("~/Utils/Excel/" + fileName); await Utils.ExportExcel.GenerateXLSRegistrationInprocess(registrationInterviews, filePath); return(File(filePath, "application/vnd.ms-excel", fileName)); } else if (id == 1) { List <RegistrationInterview> registrationInterviews = registrationInterviewRepository.GetAllRegistrationInterviewByManagementUnitId(usersession.ManagementUnitId); string fileName = string.Concat("ds-dangky.xlsx"); string filePath = System.Web.HttpContext.Current.Server.MapPath("~/Utils/Excel/" + fileName); await Utils.ExportExcel.GenerateXLSRegistrationRegisted(registrationInterviews, filePath); return(File(filePath, "application/vnd.ms-excel", fileName)); } else { List <RegistrationInterview> registrationInterviews = registrationInterviewRepository.GetAllRegistrationInterviewByManagementUnitIdValidRegistration(usersession.ManagementUnitId); string fileName = string.Concat("ds-hoplehoso.xlsx"); string filePath = System.Web.HttpContext.Current.Server.MapPath("~/Utils/Excel/" + fileName); await Utils.ExportExcel.GenerateXLSRegistrationIsValid(registrationInterviews, filePath); return(File(filePath, "application/vnd.ms-excel", fileName)); } }