Files
stream-cinema/StreamCinemaWeb/Pages/LinkPage.cs

43 lines
1.2 KiB
C#

using System;
using System.Web;
using StreamCinema.Webshare;
using StreamCinemaLib.API;
using StreamCinemaWeb.Layouts;
using LinkGenerator = StreamCinema.Webshare.LinkGenerator;
namespace StreamCinemaWeb.Pages;
public class LinkPage : BasicLayout
{
private readonly string _provider;
private readonly string _ident;
private readonly string _name;
private readonly string _title;
public LinkPage(string provider, string ident, string name, string title)
{
this._provider = provider;
this._ident = ident;
this._name = name;
this._title = title;
}
protected override string Title => _title;
protected override async Task RenderContentAsync(HttpRequest req, TextWriter w)
{
w.WriteLine("<h1>" + HttpUtility.HtmlEncode(_title) + "</h1>");
Uri link;
switch (_provider)
{
case "webshare": link = await LinkGenerator.GenerateDownloadLinkAsync(_ident, _name, req.HttpContext.RequestAborted); break;
default:
w.WriteLine("<em>Provider '" + HttpUtility.HtmlEncode(_provider) + "' není aktuálně podporován.</em>");
return;
}
w.WriteLine("<div><a href=\"" + link.ToString() + "\">" + HttpUtility.HtmlEncode(link.ToString()) + "</a></div>");
}
}