Skip to content

Commit

Permalink
Moved impressum to json
Browse files Browse the repository at this point in the history
  • Loading branch information
bartimaeusnek committed Jul 2, 2020
1 parent 99c0d97 commit f731fc8
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 37 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/CropCalulator/
/.idea/
/.github/
/CropApp/bin/
CropCalulator/
.idea/
.github/
CropApp/bin/
/CropApp/wwwroot/BreedingDict10000.json
/CropApp/wwwroot/css/site.min.css
/CropApp/wwwroot/js/site.min.js
11 changes: 0 additions & 11 deletions CropApp/Backend/PathCalculation.cs

This file was deleted.

6 changes: 6 additions & 0 deletions CropApp/CropApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
<Content Remove="wwwroot\Impressum.json" />
<EmbeddedResource Include="wwwroot\Impressum.json">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
Expand Down
100 changes: 100 additions & 0 deletions CropApp/Frontend/ImpressumData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
namespace CropApp.Frontend
{
public class ImpressumData
{
public TMG5 tmg5;
public RStV rStV;
public Contact contact;
public IDs ids;

public string ByFirstName;
public string BySurName;

public string Conservancy;

public ImpressumData() { }

public ImpressumData(TMG5 tmg5, RStV rStV, Contact contact, IDs ids, string byFirstName, string bySurName, string conservancy)
{
this.tmg5 = tmg5;
this.rStV = rStV;
this.contact = contact;
this.ids = ids;
this.ByFirstName = byFirstName;
this.BySurName = bySurName;
this.Conservancy = conservancy;
}

public class Contact
{
public string FoneAreaCode;
public string FoneNumber;
public string FaxAreaCode;
public string FaxNumber;
public string EMail;

public Contact() { }

public Contact(string foneAreaCode, string foneNumber, string faxAreaCode, string faxNumber, string eMail)
{
this.FoneAreaCode = foneAreaCode;
this.FoneNumber = foneNumber;
this.FaxAreaCode = faxAreaCode;
this.FaxNumber = faxNumber;
this.EMail = eMail;
}
}

public class RStV
{
public string FirstName;
public string SurName;
public string PLZ;
public string City;
public string Adress;

public RStV() { }
public RStV(string firstName, string surName, string adress, string plz, string city)
{
this.FirstName = firstName;
this.SurName = surName;
this.PLZ = plz;
this.City = city;
this.Adress = adress;
}
}

public class TMG5
{
public string FirstName;
public string SurName;
public string PLZ;
public string City;
public string Adress;
public TMG5() { }

public TMG5(string firstName, string surName, string adress, string plz, string city)
{
this.FirstName = firstName;
this.SurName = surName;
this.PLZ = plz;
this.City = city;
this.Adress = adress;
}
}

public class IDs
{
public string VAT;
public string Economic;
public IDs() { }

public IDs(string vat, string economic)
{
this.VAT = vat;
this.Economic = economic;
}
}

}
}
26 changes: 13 additions & 13 deletions CropApp/Pages/Impressum.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@
<h1>@ViewData["Title"]</h1>
<p>Angaben gemäß § 5 TMG</p>
<p>
Max Muster <br>
Musterweg <br>
12345 Musterstadt <br>
@Model.Data.tmg5.FirstName @Model.Data.tmg5.SurName<br>
@Model.Data.tmg5.Adress <br>
@Model.Data.tmg5.PLZ @Model.Data.tmg5.City <br>
</p>
<p>
<strong>Vertreten durch: </strong><br>
Max Muster<br>
@Model.Data.ByFirstName @Model.Data.BySurName<br>
</p>
<p>
<strong>Kontakt:</strong> <br>
Telefon: 01234-789456<br>
Fax: 1234-56789<br>
E-Mail: <a href="mailto:[email protected]">max@muster.de</a> <br>
Telefon: @Model.Data.contact.FoneAreaCode-@Model.Data.contact.FoneNumber<br>
Fax: @Model.Data.contact.FaxAreaCode-@Model.Data.contact.FaxNumber<br>
E-Mail: <a href="mailto:@Model.Data.contact.EMail">@Model.Data.contact.EMail</a> <br>
</p>
<p>
<strong>Umsatzsteuer-ID: </strong><br>
Umsatzsteuer-Identifikationsnummer gemäß §27a Umsatzsteuergesetz: Musterustid.<br><br>
Umsatzsteuer-Identifikationsnummer gemäß §27a Umsatzsteuergesetz: @Model.Data.ids.VAT<br><br>
<strong>Wirtschafts-ID: </strong><br>
Musterwirtschaftsid<br>
@Model.Data.ids.Economic<br>
</p>
<p>
<strong>Aufsichtsbehörde:</strong><br>
Musteraufsicht Musterstadt<br>
@Model.Data.Conservancy<br>
</p>
<p>
<strong>Verantwortlich für den Inhalt nach § 55 Abs. 2 RStV:</strong><br>
Max Muster <br>
Musterweg<br>
12345 Musterstadt <br>
@Model.Data.rStV.FirstName @Model.Data.rStV.SurName<br>
@Model.Data.rStV.Adress <br>
@Model.Data.rStV.PLZ @Model.Data.rStV.City <br>
</p>
<p>
<strong>Haftungsausschluss: </strong><br><br>
Expand Down
12 changes: 5 additions & 7 deletions CropApp/Pages/Impressum.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CropApp.Frontend;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;

namespace CropApp.Pages
{
public class ImpressumModel : PageModel
{
private readonly ILogger<ImpressumModel> _logger;

[BindProperty(SupportsGet = true)]
public ImpressumData Data { get; } = Program.ImpressumData;

public ImpressumModel(ILogger<ImpressumModel> logger) => this._logger = logger;
public ImpressumModel() { }

public void OnGet() { }
}
Expand Down
9 changes: 7 additions & 2 deletions CropApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
Expand All @@ -13,20 +12,26 @@ namespace CropApp
{
public class Program
{
public static ImpressumData ImpressumData;
public static async Task Main(string[] args)
{

TypeDescriptor.AddAttributes(typeof((string, string)),
new TypeConverterAttribute(typeof(TypeConverterStringTouple)));

//TODO: Simple Backend JSON config

using var r = new StreamReader("wwwroot/CropRegistry.json");
using var ir = new StreamReader("wwwroot/Impressum.json");
var json = await r.ReadToEndAsync();
var ijson = ir.ReadToEndAsync();

CropCalculation.AllCrops = JsonConvert.DeserializeObject<List<CropModel>>(json);
for (var i = 0; i < CropCalculation.AllCrops.Count; i++) CropCalculation.AllCrops[i].interalID = i;
await CropCalculation.ProcessBreeding();

ImpressumData = JsonConvert.DeserializeObject<ImpressumData>(await ijson);

await CreateHostBuilder(args).Build().RunAsync();
}

Expand Down
1 change: 1 addition & 0 deletions CropApp/wwwroot/Impressum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"tmg5":{"FirstName":"Max","SurName":"Muster","PLZ":"12345","City":"Musterstadt","Adress":"Musterweg 1"},"rStV":{"FirstName":"Max","SurName":"Muster","PLZ":"12345","City":"Musterstadt","Adress":"Musterweg 1"},"contact":{"FoneAreaCode":"01234","FoneNumber":"789456","FaxAreaCode":"01234","FaxNumber":"789456","EMail":"[email protected]"},"ids":{"VAT":"Musterustid.","Economic":"Musterwirtschaftsid"},"ByFirstName":"Max","BySurName":"Muster","Conservancy":"Musteraufsicht Musterstadt"}

0 comments on commit f731fc8

Please sign in to comment.