public async Task <IActionResult> ExportClassAttendanceToExcel() { var applicationDbContext = _context.Classes.Include(c => c.Session) .Include(c => c.Children) .Where(c => c.VBSId == this.CurrentVBSId && c.VBS.TenantId == this.TenantId) .OrderBy(c => c.SessionId) .ThenBy(c => c.Grade) .ThenBy(c => c.Name); List <Classroom> dbClassrooms = await applicationDbContext.ToListAsync(); string tenantName = _context.Tenants .Where(t => t.Id == this.TenantId).First().Name; string theme = _context.VBS .Where(v => v.Id == this.CurrentVBSId).First().ThemeName; string fileName = tenantName + " - " + theme + " - " + "Attendance.xlsx"; byte[] filecontent = ExcelExportHelper.ExportAttendanceExcel(dbClassrooms); return(File(filecontent, ExcelExportHelper.ExcelContentType, fileName)); }