add method to generate a pdf file of the race session.
this may move to api, not sure.
This commit is contained in:
parent
43f6899ddb
commit
610a69a18e
@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using System.Dynamic;
|
||||
using System.IO;
|
||||
using Nancy;
|
||||
using Nancy.ViewEngines;
|
||||
|
||||
namespace RaceLapTimer.Modules
|
||||
{
|
||||
@ -8,10 +11,36 @@ namespace RaceLapTimer.Modules
|
||||
public HistoryModule():base("/history")
|
||||
{
|
||||
Get[""] = args => GetHistoryHomePage();
|
||||
Get["/pdf/{id}"] = args => GetPdfFile(args);
|
||||
}
|
||||
|
||||
private dynamic GetPdfFile(dynamic args)
|
||||
{
|
||||
var raceSessionId = (int)args.Id;
|
||||
ViewLocationContext viewLocationContext = new ViewLocationContext()
|
||||
{
|
||||
Context = Context,
|
||||
ModuleName = base.GetType().Name,
|
||||
ModulePath = ModulePath
|
||||
};
|
||||
var rendered = ViewFactory.RenderView("HistoryIndex.cshtml", null, viewLocationContext);
|
||||
var content = "";
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
rendered.Contents.Invoke(ms);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
using (TextReader reader = new StreamReader(ms))
|
||||
{
|
||||
content = reader.ReadToEnd();
|
||||
}
|
||||
};
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private dynamic GetHistoryHomePage()
|
||||
{
|
||||
|
||||
|
||||
return View["HistoryIndex.cshtml"];
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user