public void Respond()
        {
            try
            {
                DataDownloadBespokeParameters parameters = new DataDownloadBespokeParameters(Context.Request.Params);

                var fileInfo = new PracticeProfileFileInfo(parameters.ProfileKey,
                    parameters.GroupIds,
                    parameters.AreaCode);

                byte[] bytes;

                if (ApplicationConfiguration.UseFileCache && fileInfo.DoesFileExist)
                {
                    bytes = File.ReadAllBytes(fileInfo.FilePath);
                }
                else
                {
                    PracticeProfileDataBuilder builder = new PracticeProfileDataBuilder(UsePopulationData(parameters))
                    {
                        AreaCode = parameters.AreaCode,
                        GroupIds = parameters.GroupIds,
                        AreaTypeId = parameters.AreaTypeId
                    };

                    var workBook = builder.BuildWorkbook();
                    ExcelFileWriter writer = new ExcelFileWriter
                    {
                        UseFileCache = ApplicationConfiguration.UseFileCache
                    };
                    bytes = writer.Write(fileInfo, workBook);
                }

                var response = Context.Response;
                ExportHelper.SetResponseAsExcelFile(response,
                    GetDataDownload.DownloadedFileName + "." + fileInfo.FileExtension);
                response.BinaryWrite(bytes);
            }
            catch (Exception ex)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                ExceptionLog.LogException(ex, Context.Request.Url.AbsoluteUri);
            }

            Context.Response.Flush();
        }
 public void TestSingleGroupId()
 {
     PracticeProfileFileInfo maker = new PracticeProfileFileInfo(
         "pp", new List<int>{1}, "eng");
     Assert.AreEqual("pp-eng-1.xlsx", maker.FileName);
 }
        private void WriteExcelFile(string profileKey, int groupId)
        {
            var builder = new PracticeProfileDataBuilder(UsePopulationData(profileKey))
            {
                AreaCode = AreaCodes.England,
                GroupIds = new List<int> { groupId },
                AreaTypeId = AreaTypeIds.Ccg
            };

            var workBook = builder.BuildWorkbook();
            var fileInfo = new PracticeProfileFileInfo(profileKey,
                new List<int> { groupId }, AreaCodes.England);
            _excelFileWriter.Write(fileInfo, workBook);
        }
 public void TestMultipleGroupIds()
 {
     PracticeProfileFileInfo maker = new PracticeProfileFileInfo(
         "pp", new List<int> { 1,2 }, "eng");
     Assert.AreEqual("pp-eng-1-2.xlsx", maker.FileName);
 }