53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.IO;
|
|
|
|
namespace WGneu.Documents {
|
|
public class Document {
|
|
|
|
public Document(string title) {
|
|
Title = title;
|
|
Header = "Winzergenossenschaft Matzen";
|
|
Footer = "Winzergenossenschaft für Matzen und Umgebung reg. Gen.m.b.H.";
|
|
Date = DateTime.Today;
|
|
}
|
|
|
|
public string Title { get; set; }
|
|
|
|
public string Header { get; set; }
|
|
|
|
public string Footer { get; set; }
|
|
|
|
public string FullDateString {
|
|
get {
|
|
return Date.ToString("dddd, d. MMMM yyyy");
|
|
}
|
|
}
|
|
|
|
public DateTime Date { get; set; }
|
|
|
|
private async Task<string> Render() {
|
|
if (this is BusinessLetter bl) {
|
|
return await Pdf.CompileRenderAsync("BusinessLetter.cshtml", bl);
|
|
} else if (this is BusinessDocument bd) {
|
|
return await Pdf.CompileRenderAsync("BusinessDocument.cshtml", bd);
|
|
} else {
|
|
return await Pdf.CompileRenderAsync("Document.cshtml", this);
|
|
}
|
|
}
|
|
|
|
private async Task<string> SaveHtml() {
|
|
await File.WriteAllTextAsync("razor_test.html", await Render());
|
|
return "";
|
|
}
|
|
|
|
public async Task<string> Save() {
|
|
await SaveHtml();
|
|
return "";
|
|
}
|
|
}
|
|
}
|