private vmEventManager_SummaryReport GetSummaryReport(vmEventManager_EventFilter performanceFilter)
        {
            var rpt = new vmEventManager_SummaryReport();

            if (performanceFilter.EventId.HasValue)
            {
                var evt = _service.GetEventById(performanceFilter.EventId.Value);
                rpt.EventName = evt.GeneralLocality;

                var regs = _service.GetRegistrationsByEventId(evt.EventId);
                var waves = _service.GetWavesByEventID(evt.EventId);

                int waveNumber = 1;
                foreach (var wave in waves)
                {
                    var waveData = new SummaryReportWaveData
                        {
                            EventWaveID = wave.EventWaveId,
                            WaveNumber = waveNumber++,
                            StartTime = wave.StartTime,
                            Active = wave.IsActive.ToString(),
                            NumParticipants = regs.Count(x => x.EventWaveId == wave.EventWaveId && x.RegistrationStatus == RegistrationStatus.Active)
                        };
                    rpt.WaveData.Add(waveData);
                }
            }

            return rpt;
        }
        private FileResult ExportSummaryReport(vmEventManager_SummaryReport report, vmEventManager_EventFilter filter)
        {
            int rowNumber = 0;
            NPOI.SS.UserModel.IRow row;

            //Create new Excel workbook
            var workbook = new HSSFWorkbook();

            //Create new Excel sheet
            var sheet = workbook.CreateSheet();
            sheet.SetColumnWidth(0, 11 * 256);
            sheet.SetColumnWidth(1, 44 * 256);
            sheet.SetColumnWidth(2, 33 * 256);
            sheet.SetColumnWidth(3, 11 * 256);
            sheet.SetColumnWidth(4, 11 * 256);

            var allStyles = ReportUtilities.CreateStyles(workbook);

            ReportUtilities.ExportReportHeader("Summary Report", sheet, allStyles, ref rowNumber);
            if (filter.EventId != null)
            {
                var thisEvent = _service.GetEventById(filter.EventId.Value);

                row = sheet.CreateRow(rowNumber++);
                ReportUtilities.CreateCell(row, 0, string.Format("{0} - {1}", thisEvent.GeneralLocality, thisEvent.EventDates.Min().DateOfEvent.ToShortDateString()), allStyles.Header2Style);
            }
            sheet.CreateRow(rowNumber++);
            row = sheet.CreateRow(rowNumber++);
            ReportUtilities.CreateCell(row, 0, "Location", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, 1, "Wave Number", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, 2, "Start Time", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, 3, "Num Participants", allStyles.TitleStyle);
            ReportUtilities.CreateCell(row, 4, "Active", allStyles.TitleStyle);
            foreach (var wave in report.WaveData)
            {
                row = sheet.CreateRow(rowNumber++);
                ReportUtilities.CreateCell(row, 0, report.EventName, allStyles.LeftAligned);
                ReportUtilities.CreateCell(row, 1, wave.WaveNumber, allStyles.RightAligned);
                ReportUtilities.CreateCell(row, 2, wave.StartTime.ToString("MM/dd/yyyy HH:mm"), allStyles.RightAligned);
                ReportUtilities.CreateCell(row, 3, wave.NumParticipants, allStyles.RightAligned);
                ReportUtilities.CreateCell(row, 4, wave.Active, allStyles.LeftAligned);
            }

            //Write the workbook to a memory stream
            var output = new MemoryStream();
            workbook.Write(output);

            //Return the result to the end user

            return File(output.ToArray(),   //The binary data of the XLS file
                "application/vnd.ms-excel", //MIME type of Excel files
                "SummaryExport.xls");     //Suggested file name in the "Save as" dialog which will be displayed to the end user
        }