Move downloads to new controller
This commit is contained in:
@@ -108,83 +108,7 @@ namespace LeafWeb.WebCms.Controllers
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
public ActionResult DownloadInput(int id)
|
||||
{
|
||||
return GetInputZip(id);
|
||||
}
|
||||
|
||||
public ActionResult DownloadOutputToUser(int id)
|
||||
{
|
||||
return GetOutputZip(id, LeafOutputFileType.ToUser);
|
||||
}
|
||||
|
||||
public ActionResult DownloadOutputNotToUser(int id)
|
||||
{
|
||||
return GetOutputZip(id, LeafOutputFileType.NotToUser);
|
||||
}
|
||||
|
||||
public ActionResult DownloadOutputCleanedInput(int id)
|
||||
{
|
||||
return GetOutputZip(id, LeafOutputFileType.CleanedInput);
|
||||
}
|
||||
|
||||
public ActionResult DownloadResultsInputZip(LeafDataQuery query)
|
||||
{
|
||||
return GetResults(query, LeafInput.GetInputFilesZip, $"LeafWeb_{DateTime.Now:yyyy-dd-MM--HH-mm-ss}_Input.zip");
|
||||
}
|
||||
|
||||
public ActionResult DownloadResultsOutputZip(LeafDataQuery query)
|
||||
{
|
||||
return GetResults(query, LeafInput.GetOutputFilesZip_ToUser, $"LeafWeb_{DateTime.Now:yyyy-dd-MM--HH-mm-ss}_Output.zip");
|
||||
}
|
||||
|
||||
private ActionResult GetOutputZip(int id, LeafOutputFileType type)
|
||||
{
|
||||
var leafInput = DataService.GetLeafInput(id);
|
||||
|
||||
if (leafInput == null)
|
||||
return View("DownloadNotFound");
|
||||
|
||||
var zip = leafInput.GetOutputFileZip(type);
|
||||
|
||||
var filename = $"{leafInput.Identifier.FilterValidFilename()}_{type}.zip";
|
||||
|
||||
return new FileContentResult(zip, "application/zip") { FileDownloadName = filename };
|
||||
}
|
||||
|
||||
private ActionResult GetInputZip(int id)
|
||||
{
|
||||
var leafInput = DataService.GetLeafInput(id);
|
||||
|
||||
if (leafInput == null)
|
||||
return View("DownloadNotFound");
|
||||
|
||||
var zip = leafInput.GetInputFileZip();
|
||||
|
||||
var filename = $"{leafInput.Identifier.FilterValidFilename()}_Input.zip";
|
||||
|
||||
return new FileContentResult(zip, "application/zip") { FileDownloadName = filename };
|
||||
}
|
||||
|
||||
private ActionResult GetResults(LeafDataQuery query, Func<IEnumerable<LeafInput>, byte[]> getZip, string filename)
|
||||
{
|
||||
var resultItems =
|
||||
DataService.GetLeafInputsOrdered();
|
||||
|
||||
resultItems
|
||||
= QueryFilter.Search(resultItems, query, Members.GetCurrentLoginStatus()?.Email);
|
||||
|
||||
if (resultItems == null)
|
||||
return View("DownloadNotFound");
|
||||
|
||||
var zip = getZip(resultItems);
|
||||
|
||||
//var filename = $"LeafWeb_{DateTime.Now:yyyy-dd-MM--HH-mm-ss}_Input.zip";
|
||||
|
||||
return new FileContentResult(zip, "application/zip") { FileDownloadName = filename };
|
||||
}
|
||||
|
||||
[ActionLog]
|
||||
[ActionLog]
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
var leafInput = DataService.GetLeafInput(id);
|
||||
|
||||
Reference in New Issue
Block a user