Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Commit

Permalink
removing the try catch for the CSV
Browse files Browse the repository at this point in the history
  • Loading branch information
scottcowan committed Apr 11, 2017
1 parent c871352 commit 26482a6
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions src/Sfa.Roatp.Register.Web/Controllers/DownloadController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,22 @@ public ActionResult Index()

public ActionResult Csv()
{
try
{
var providers = _getProviders.GetAllProviders().Where(x => x.IsDateValid(DateTime.Now));
var result = providers.Select(CsvProviderMapper.Map);
var providers = _getProviders.GetAllProviders().Where(x => x.IsDateValid(DateTime.UtcNow));
var result = providers.Select(CsvProviderMapper.Map);

using (var memoryStream = new MemoryStream())
using (var memoryStream = new MemoryStream())
{
using (var streamWriter = new StreamWriter(memoryStream))
{
using (var streamWriter = new StreamWriter(memoryStream))
using (var csvWriter = new CsvWriter(streamWriter))
{
using (var csvWriter = new CsvWriter(streamWriter))
{
csvWriter.WriteRecords(result);
streamWriter.Flush();
memoryStream.Position = 0;
return File(memoryStream.ToArray(), "text/csv", $"roatp-{DateTime.Today.ToString("yyyy-MM-dd")}.csv");
}
csvWriter.WriteRecords(result);
streamWriter.Flush();
memoryStream.Position = 0;
return File(memoryStream.ToArray(), "text/csv", $"roatp-{DateTime.UtcNow.ToString("yyyy-MM-dd")}.csv");
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
}
}

0 comments on commit 26482a6

Please sign in to comment.