From c8f95c7e18671e5df158ab45638ba7373e907505 Mon Sep 17 00:00:00 2001
From: Laura Hausmann
Date: Tue, 3 May 2022 00:59:32 +0200
Subject: [PATCH] Use SSO auth, remove legacy deutschebahn endpoints
---
trainav.web/JSON/CardResponse/CardResponse.cs | 214 ---------
.../ListOrdersResponse/ListOrdersResponse.cs | 75 ---
trainav.web/JSON/OEAPIResponse.cs | 28 +-
trainav.web/JSON/TicketResponse.cs | 434 ------------------
trainav.web/Migrations.cs | 30 +-
trainav.web/Pages/Card.cshtml | 16 -
trainav.web/Pages/Card.cshtml.cs | 65 ---
trainav.web/Pages/Cards.cshtml | 169 -------
trainav.web/Pages/Cards.cshtml.cs | 54 ---
trainav.web/Pages/Delete.cshtml | 98 ++--
trainav.web/Pages/Delete.cshtml.cs | 29 +-
trainav.web/Pages/Index.cshtml | 174 ++++---
trainav.web/Pages/Index.cshtml.cs | 9 +-
trainav.web/Pages/Inspection.cshtml | 151 ------
trainav.web/Pages/Inspection.cshtml.cs | 29 --
trainav.web/Pages/Login.cshtml | 30 --
trainav.web/Pages/Logout.cshtml | 7 -
trainav.web/Pages/Logout.cshtml.cs | 9 -
trainav.web/Pages/OEAPI.cshtml | 12 +-
trainav.web/Pages/OEAPI.cshtml.cs | 14 +-
trainav.web/Pages/Plain.cshtml | 44 --
trainav.web/Pages/Plain.cshtml.cs | 20 -
trainav.web/Pages/Register.cshtml | 29 --
trainav.web/Pages/Register.cshtml.cs | 31 --
trainav.web/Pages/Shared/_Layout.cshtml | 84 ++--
trainav.web/Pages/Ticket.cshtml | 16 -
trainav.web/Pages/Ticket.cshtml.cs | 255 ----------
trainav.web/Pages/Trip.cshtml | 309 ++++++-------
trainav.web/Pages/Trip.cshtml.cs | 18 +-
trainav.web/Utils/AuthUtil.cs | 17 +
.../StringExtensions.cs} | 27 +-
trainav.web/database/Database.cs | 5 +-
trainav.web/database/Tables/Card.cs | 36 --
trainav.web/database/Tables/Leg.cs | 4 +-
trainav.web/database/Tables/Ticket.cs | 22 -
trainav.web/database/Tables/TicketLeg.cs | 27 --
trainav.web/database/Tables/User.cs | 4 +-
trainav.web/trainav.web.csproj | 39 --
trainav.web/wwwroot/css/site.css | 86 ++--
39 files changed, 439 insertions(+), 2281 deletions(-)
delete mode 100644 trainav.web/JSON/CardResponse/CardResponse.cs
delete mode 100644 trainav.web/JSON/ListOrdersResponse/ListOrdersResponse.cs
delete mode 100644 trainav.web/JSON/TicketResponse.cs
delete mode 100644 trainav.web/Pages/Card.cshtml
delete mode 100644 trainav.web/Pages/Card.cshtml.cs
delete mode 100644 trainav.web/Pages/Cards.cshtml
delete mode 100644 trainav.web/Pages/Cards.cshtml.cs
delete mode 100644 trainav.web/Pages/Inspection.cshtml
delete mode 100644 trainav.web/Pages/Inspection.cshtml.cs
delete mode 100644 trainav.web/Pages/Login.cshtml
delete mode 100644 trainav.web/Pages/Logout.cshtml
delete mode 100644 trainav.web/Pages/Logout.cshtml.cs
delete mode 100644 trainav.web/Pages/Plain.cshtml
delete mode 100644 trainav.web/Pages/Plain.cshtml.cs
delete mode 100644 trainav.web/Pages/Register.cshtml
delete mode 100644 trainav.web/Pages/Register.cshtml.cs
delete mode 100644 trainav.web/Pages/Ticket.cshtml
delete mode 100644 trainav.web/Pages/Ticket.cshtml.cs
create mode 100644 trainav.web/Utils/AuthUtil.cs
rename trainav.web/{Pages/Login.cshtml.cs => Utils/StringExtensions.cs} (55%)
delete mode 100644 trainav.web/database/Tables/Card.cs
delete mode 100644 trainav.web/database/Tables/Ticket.cs
delete mode 100644 trainav.web/database/Tables/TicketLeg.cs
diff --git a/trainav.web/JSON/CardResponse/CardResponse.cs b/trainav.web/JSON/CardResponse/CardResponse.cs
deleted file mode 100644
index 7447e49..0000000
--- a/trainav.web/JSON/CardResponse/CardResponse.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-//
-//
-// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
-//
-// using trainav.web.JSON.CardResponse;
-//
-// var cardResponse = CardResponse.FromJson(jsonString);
-
-using System.Collections.Generic;
-using System.Globalization;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
-
-namespace trainav.web.JSON.CardResponse {
- public partial class CardResponse {
- [JsonProperty("?xml", NullValueHandling = NullValueHandling.Ignore)]
- public Xml Xml { get; set; }
-
- [JsonProperty("rporderdetails", NullValueHandling = NullValueHandling.Ignore)]
- public Rporderdetails Rporderdetails { get; set; }
- }
-
- public class Rporderdetails {
- [JsonProperty("@version", NullValueHandling = NullValueHandling.Ignore)]
- public string Version { get; set; }
-
- [JsonProperty("rpheader", NullValueHandling = NullValueHandling.Ignore)]
- public Rpheader Rpheader { get; set; }
-
- [JsonProperty("order", NullValueHandling = NullValueHandling.Ignore)]
- public Order Order { get; set; }
- }
-
- public class Order {
- [JsonProperty("@cdt", NullValueHandling = NullValueHandling.Ignore)]
- public string Cdt { get; set; }
-
- [JsonProperty("@cid", NullValueHandling = NullValueHandling.Ignore)]
- public string Cid { get; set; }
-
- [JsonProperty("@ddt", NullValueHandling = NullValueHandling.Ignore)]
- public string Ddt { get; set; }
-
- [JsonProperty("@fkat", NullValueHandling = NullValueHandling.Ignore)]
- public string Fkat { get; set; }
-
- [JsonProperty("@ldt", NullValueHandling = NullValueHandling.Ignore)]
- public string Ldt { get; set; }
-
- [JsonProperty("@on", NullValueHandling = NullValueHandling.Ignore)]
- public string On { get; set; }
-
- [JsonProperty("@pg", NullValueHandling = NullValueHandling.Ignore)]
- public string Pg { get; set; }
-
- [JsonProperty("@sdt", NullValueHandling = NullValueHandling.Ignore)]
- public string Sdt { get; set; }
-
- [JsonProperty("@version", NullValueHandling = NullValueHandling.Ignore)]
- public string Version { get; set; }
-
- [JsonProperty("@vfrom", NullValueHandling = NullValueHandling.Ignore)]
- public string Vfrom { get; set; }
-
- [JsonProperty("@vto", NullValueHandling = NullValueHandling.Ignore)]
- public string Vto { get; set; }
-
- [JsonProperty("@zweg", NullValueHandling = NullValueHandling.Ignore)]
- public string Zweg { get; set; }
-
- [JsonProperty("tcklist", NullValueHandling = NullValueHandling.Ignore)]
- public Tcklist Tcklist { get; set; }
-
- [JsonProperty("posinfolist", NullValueHandling = NullValueHandling.Ignore)]
- public Posinfolist Posinfolist { get; set; }
- }
-
- public class Posinfolist {
- [JsonProperty("posinfo", NullValueHandling = NullValueHandling.Ignore)]
- public Posinfo Posinfo { get; set; }
- }
-
- public class Posinfo {
- [JsonProperty("@dir", NullValueHandling = NullValueHandling.Ignore)]
- public string Dir { get; set; }
-
- [JsonProperty("@dirlabel", NullValueHandling = NullValueHandling.Ignore)]
- public string Dirlabel { get; set; }
-
- [JsonProperty("@posnr", NullValueHandling = NullValueHandling.Ignore)]
- public string Posnr { get; set; }
-
- [JsonProperty("@shownr", NullValueHandling = NullValueHandling.Ignore)]
- public string Shownr { get; set; }
-
- [JsonProperty("@state", NullValueHandling = NullValueHandling.Ignore)]
- public string State { get; set; }
-
- [JsonProperty("@type", NullValueHandling = NullValueHandling.Ignore)]
- public string Type { get; set; }
-
- [JsonProperty("@typeinfo", NullValueHandling = NullValueHandling.Ignore)]
- public string Typeinfo { get; set; }
-
- [JsonProperty("@vfo", NullValueHandling = NullValueHandling.Ignore)]
- public string Vfo { get; set; }
-
- [JsonProperty("@vto", NullValueHandling = NullValueHandling.Ignore)]
- public string Vto { get; set; }
-
- [JsonProperty("childlist")] public object Childlist { get; set; }
- }
-
- public class Tcklist {
- [JsonProperty("tck", NullValueHandling = NullValueHandling.Ignore)]
- public Tck Tck { get; set; }
- }
-
- public class Tck {
- [JsonProperty("@posnr", NullValueHandling = NullValueHandling.Ignore)]
- public string Posnr { get; set; }
-
- [JsonProperty("htdata", NullValueHandling = NullValueHandling.Ignore)]
- public Htdata Htdata { get; set; }
-
- [JsonProperty("mtk", NullValueHandling = NullValueHandling.Ignore)]
- public Mtk Mtk { get; set; }
-
- [JsonProperty("bahncardimage", NullValueHandling = NullValueHandling.Ignore)]
- public Bahncardimage Bahncardimage { get; set; }
- }
-
- public class Bahncardimage {
- [JsonProperty("#cdata-section", NullValueHandling = NullValueHandling.Ignore)]
- public string CdataSection { get; set; }
- }
-
- public class Htdata {
- [JsonProperty("ht", NullValueHandling = NullValueHandling.Ignore)]
- public List Ht { get; set; }
- }
-
- public class Ht {
- [JsonProperty("@name", NullValueHandling = NullValueHandling.Ignore)]
- public string Name { get; set; }
-
- [JsonProperty("@pos", NullValueHandling = NullValueHandling.Ignore)]
- public string Pos { get; set; }
-
- [JsonProperty("@type", NullValueHandling = NullValueHandling.Ignore)]
- public string Type { get; set; }
-
- [JsonProperty("#text", NullValueHandling = NullValueHandling.Ignore)]
- public string Text { get; set; }
- }
-
- public class Mtk {
- [JsonProperty("@dir", NullValueHandling = NullValueHandling.Ignore)]
- public string Dir { get; set; }
-
- [JsonProperty("@status", NullValueHandling = NullValueHandling.Ignore)]
- public string Status { get; set; }
-
- [JsonProperty("txt", NullValueHandling = NullValueHandling.Ignore)]
- public string Txt { get; set; }
-
- [JsonProperty("zb", NullValueHandling = NullValueHandling.Ignore)]
- public string Zb { get; set; }
-
- [JsonProperty("nvplist", NullValueHandling = NullValueHandling.Ignore)]
- public Nvplist Nvplist { get; set; }
- }
-
- public class Nvplist {
- [JsonProperty("nvp", NullValueHandling = NullValueHandling.Ignore)]
- public List Nvp { get; set; }
- }
-
- public class Nvp {
- [JsonProperty("@name", NullValueHandling = NullValueHandling.Ignore)]
- public string Name { get; set; }
-
- [JsonProperty("#text", NullValueHandling = NullValueHandling.Ignore)]
- public string Text { get; set; }
- }
-
- public class Rpheader {
- [JsonProperty("@tnr", NullValueHandling = NullValueHandling.Ignore)]
- public string Tnr { get; set; }
-
- [JsonProperty("@ts", NullValueHandling = NullValueHandling.Ignore)]
- public string Ts { get; set; }
- }
-
- public class Xml {
- [JsonProperty("@version", NullValueHandling = NullValueHandling.Ignore)]
- public string Version { get; set; }
-
- [JsonProperty("@encoding", NullValueHandling = NullValueHandling.Ignore)]
- public string Encoding { get; set; }
- }
-
- public partial class CardResponse {
- public static CardResponse FromJson(string json) => JsonConvert.DeserializeObject(json, Converter.Settings);
- }
-
- internal static class Converter {
- public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings {
- MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
- DateParseHandling = DateParseHandling.None,
- Converters = {new IsoDateTimeConverter {DateTimeStyles = DateTimeStyles.AssumeUniversal}}
- };
- }
-}
diff --git a/trainav.web/JSON/ListOrdersResponse/ListOrdersResponse.cs b/trainav.web/JSON/ListOrdersResponse/ListOrdersResponse.cs
deleted file mode 100644
index eea184b..0000000
--- a/trainav.web/JSON/ListOrdersResponse/ListOrdersResponse.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-//
-// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
-//
-// using trainav.web.JSON;
-//
-// var listOrdersResponse = ListOrdersResponse.FromJson(jsonString);
-
-using System.Collections.Generic;
-using Newtonsoft.Json;
-
-namespace trainav.web.JSON.ListOrdersResponse {
- public partial class ListOrdersResponse {
- [JsonProperty("?xml", NullValueHandling = NullValueHandling.Ignore)]
- public Xml Xml { get; set; }
-
- [JsonProperty("rporderheadlist", NullValueHandling = NullValueHandling.Ignore)]
- public Rporderheadlist Rporderheadlist { get; set; }
- }
-
- public class Rporderheadlist {
- [JsonProperty("@version", NullValueHandling = NullValueHandling.Ignore)]
- public string Version { get; set; }
-
- [JsonProperty("rpheader", NullValueHandling = NullValueHandling.Ignore)]
- public Rpheader Rpheader { get; set; }
-
- [JsonProperty("orderheadlist", NullValueHandling = NullValueHandling.Ignore)]
- public Orderheadlist Orderheadlist { get; set; }
- }
-
- public class Orderheadlist {
- [JsonProperty("orderhead", NullValueHandling = NullValueHandling.Ignore)]
- public List Orderhead { get; set; }
- }
-
- public class Orderhead {
- [JsonProperty("@ldt", NullValueHandling = NullValueHandling.Ignore)]
- public string Ldt { get; set; }
-
- [JsonProperty("@on", NullValueHandling = NullValueHandling.Ignore)]
- public string On { get; set; }
-
- [JsonProperty("authtmp", NullValueHandling = NullValueHandling.Ignore)]
- public Authtmp Authtmp { get; set; }
- }
-
- public class Authtmp {
- [JsonProperty("@htmp", NullValueHandling = NullValueHandling.Ignore)]
- public string Htmp { get; set; }
-
- [JsonProperty("@ts", NullValueHandling = NullValueHandling.Ignore)]
- public string Ts { get; set; }
- }
-
- public class Rpheader {
- [JsonProperty("@tnr", NullValueHandling = NullValueHandling.Ignore)]
- public string Tnr { get; set; }
-
- [JsonProperty("@ts", NullValueHandling = NullValueHandling.Ignore)]
- public string Ts { get; set; }
- }
-
- public class Xml {
- [JsonProperty("@version", NullValueHandling = NullValueHandling.Ignore)]
- public string Version { get; set; }
-
- [JsonProperty("@encoding", NullValueHandling = NullValueHandling.Ignore)]
- public string Encoding { get; set; }
- }
-
- public partial class ListOrdersResponse {
- public static ListOrdersResponse FromJson(string json) => JsonConvert.DeserializeObject(json, Converter.Settings);
- }
-}
\ No newline at end of file
diff --git a/trainav.web/JSON/OEAPIResponse.cs b/trainav.web/JSON/OEAPIResponse.cs
index 4392194..c223edc 100644
--- a/trainav.web/JSON/OEAPIResponse.cs
+++ b/trainav.web/JSON/OEAPIResponse.cs
@@ -13,6 +13,12 @@ namespace trainav.web.JSON {
using J = JsonPropertyAttribute;
using R = Required;
using N = NullValueHandling;
+ using System;
+ using System.Collections.Generic;
+ using System.Globalization;
+ using Newtonsoft.Json;
+ using Newtonsoft.Json.Converters;
+ using Newtonsoft.Json.Linq;
public partial class OeapiResponse {
[J("status", NullValueHandling = N.Ignore)]
@@ -259,4 +265,24 @@ namespace trainav.web.JSON {
public partial class OeapiResponse {
public static OeapiResponse FromJson(string json) => JsonConvert.DeserializeObject(json, Converter.Settings);
}
-}
\ No newline at end of file
+
+ internal static class Converter {
+ public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings {
+ MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
+ DateParseHandling = DateParseHandling.None,
+ Converters = {new IsoDateTimeConverter {DateTimeStyles = DateTimeStyles.AssumeUniversal}}
+ };
+ }
+ internal class SingleOrArrayConverter : JsonConverter {
+ public override bool CanWrite => false;
+ public override bool CanConvert(Type objectType) => objectType == typeof(List);
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
+ var token = JToken.Load(reader);
+ return token.Type == JTokenType.Array ? token.ToObject>() : new List {token.ToObject()};
+ }
+ public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
+ throw new NotImplementedException();
+ }
+ }
+
+}
diff --git a/trainav.web/JSON/TicketResponse.cs b/trainav.web/JSON/TicketResponse.cs
deleted file mode 100644
index dc0ea42..0000000
--- a/trainav.web/JSON/TicketResponse.cs
+++ /dev/null
@@ -1,434 +0,0 @@
-//
-//
-// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
-//
-// using trainav.web.JSON;
-//
-// var ticketResponse = TicketResponse.FromJson(jsonString);
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
-using Newtonsoft.Json.Linq;
-
-namespace trainav.web.JSON {
- using J = JsonPropertyAttribute;
- using R = Required;
- using NV = NullValueHandling;
-
- public partial class TicketResponse {
- [J("?xml", NullValueHandling = NV.Ignore)]
- public Xml Xml { get; set; }
-
- [J("rporderdetails", NullValueHandling = NV.Ignore)]
- public Rporderdetails Rporderdetails { get; set; }
- }
-
- public class Rporderdetails {
- [J("rpheader", NullValueHandling = NV.Ignore)]
- public Rpheader Rpheader { get; set; }
-
- [J("@version", NullValueHandling = NV.Ignore)]
- public string Version { get; set; }
-
- [J("order", NullValueHandling = NV.Ignore)]
- public Order Order { get; set; }
- }
-
- public class Order {
- [J("@cid", NullValueHandling = NV.Ignore)]
- public string Cid { get; set; }
-
- [J("@cdt", NullValueHandling = NV.Ignore)]
- public string Cdt { get; set; }
-
- [J("schedulelist", NullValueHandling = NV.Ignore)]
- public Schedulelist Schedulelist { get; set; }
-
- [J("tcklist", NullValueHandling = NV.Ignore)]
- public Tcklist Tcklist { get; set; }
-
- [J("@sdt", NullValueHandling = NV.Ignore)]
- public string Sdt { get; set; }
-
- [J("@zweg", NullValueHandling = NV.Ignore)]
- public string Zweg { get; set; }
-
- [J("@vto", NullValueHandling = NV.Ignore)]
- public string Vto { get; set; }
-
- [J("@vfrom", NullValueHandling = NV.Ignore)]
- public string Vfrom { get; set; }
-
- [J("@ldt", NullValueHandling = NV.Ignore)]
- public string Ldt { get; set; }
-
- [J("@pg", NullValueHandling = NV.Ignore)]
- public string Pg { get; set; }
-
- [J("posinfolist", NullValueHandling = NV.Ignore)]
- public Posinfolist Posinfolist { get; set; }
-
- [J("@on", NullValueHandling = NV.Ignore)]
- public string On { get; set; }
-
- [J("txt", NullValueHandling = NV.Ignore)]
- public string Txt { get; set; }
-
- [J("@hkey", NullValueHandling = NV.Ignore)]
- public string Hkey { get; set; }
-
- [J("reslist", NullValueHandling = NV.Ignore)]
- public Reslist Reslist { get; set; }
-
- [J("@ddt", NullValueHandling = NV.Ignore)]
- public string Ddt { get; set; }
-
- [J("@version", NullValueHandling = NV.Ignore)]
- public string Version { get; set; }
-
- [J("@fkat", NullValueHandling = NV.Ignore)]
- public string Fkat { get; set; }
- }
-
- public class Posinfolist {
- [J("posinfo", NullValueHandling = NV.Ignore), JsonConverter(typeof(SingleOrArrayConverter))]
- public List Posinfo { get; set; }
- }
-
- public class FluffyChildlist {
- [J("posinfo", NullValueHandling = NV.Ignore), JsonConverter(typeof(SingleOrArrayConverter))]
- public List Posinfo { get; set; }
- }
-
- public class PurplePosinfo {
- [J("@state", NullValueHandling = NV.Ignore)]
- public string State { get; set; }
-
- [J("@dir", NullValueHandling = NV.Ignore)]
- public string Dir { get; set; }
-
- [J("@posnr", NullValueHandling = NV.Ignore)]
- public string Posnr { get; set; }
-
- [J("@type", NullValueHandling = NV.Ignore)]
- public string Type { get; set; }
-
- [J("@shownr", NullValueHandling = NV.Ignore)]
- public string Shownr { get; set; }
-
- [J("@dirlabel", NullValueHandling = NV.Ignore)]
- public string Dirlabel { get; set; }
-
- [J("@vfo", NullValueHandling = NV.Ignore)]
- public string Vfo { get; set; }
-
- [J("@typeinfo", NullValueHandling = NV.Ignore)]
- public string Typeinfo { get; set; }
-
- [J("@vto", NullValueHandling = NV.Ignore)]
- public string Vto { get; set; }
-
- [J("childlist", NullValueHandling = NV.Ignore)]
- public FluffyChildlist Childlist { get; set; }
- }
-
- public class PurpleChildlist {
- [J("posinfo", NullValueHandling = NV.Ignore), JsonConverter(typeof(SingleOrArrayConverter))]
- public List Posinfo { get; set; }
- }
-
- public class PosinfoElement {
- [J("@state", NullValueHandling = NV.Ignore)]
- public string State { get; set; }
-
- [J("@dir", NullValueHandling = NV.Ignore)]
- public string Dir { get; set; }
-
- [J("@posnr", NullValueHandling = NV.Ignore)]
- public string Posnr { get; set; }
-
- [J("@type", NullValueHandling = NV.Ignore)]
- public string Type { get; set; }
-
- [J("@shownr", NullValueHandling = NV.Ignore)]
- public string Shownr { get; set; }
-
- [J("@dirlabel", NullValueHandling = NV.Ignore)]
- public string Dirlabel { get; set; }
-
- [J("@vfo", NullValueHandling = NV.Ignore)]
- public string Vfo { get; set; }
-
- [J("@typeinfo", NullValueHandling = NV.Ignore)]
- public string Typeinfo { get; set; }
-
- [J("@vto", NullValueHandling = NV.Ignore)]
- public string Vto { get; set; }
-
- [J("childlist", NullValueHandling = NV.Ignore)]
- public PurpleChildlist Childlist { get; set; }
- }
-
- public class Reslist {
- [J("res", NullValueHandling = NV.Ignore), JsonConverter(typeof(SingleOrArrayConverter))]
- public List Res { get; set; }
- }
-
- public class Re {
- [J("@tid", NullValueHandling = NV.Ignore)]
- public string Tid { get; set; }
-
- [J("@posnr", NullValueHandling = NV.Ignore)]
- public string Posnr { get; set; }
-
- [J("@dt", NullValueHandling = NV.Ignore)]
- public string Dt { get; set; }
-
- [J("nvplist", NullValueHandling = NV.Ignore)]
- public Nvplist Nvplist { get; set; }
-
- [J("@cdt", NullValueHandling = NV.Ignore)]
- public string Cdt { get; set; }
-
- [J("plaetze", NullValueHandling = NV.Ignore)]
- public Plaetze Plaetze { get; set; }
-
- [J("txt", NullValueHandling = NV.Ignore)]
- public string Txt { get; set; }
-
- [J("@tn", NullValueHandling = NV.Ignore)]
- public string Tn { get; set; }
- }
-
- public class Nvplist {
- [J("nvp", NullValueHandling = NV.Ignore)]
- public List Nvp { get; set; }
- }
-
- public class Nvp {
- [J("@name", NullValueHandling = NV.Ignore)]
- public string Name { get; set; }
-
- [J("#text", NullValueHandling = NV.Ignore)]
- public string Text { get; set; }
- }
-
- public class Plaetze {
- [J("platz", NullValueHandling = NV.Ignore), JsonConverter(typeof(SingleOrArrayConverter))]
- public List Platz { get; set; }
- }
-
- public class Platz {
- [J("platznr", NullValueHandling = NV.Ignore)]
- public string Platznr { get; set; }
-
- [J("wagennr", NullValueHandling = NV.Ignore)]
- public string Wagennr { get; set; }
- }
-
- public class Schedulelist {
- [J("out", NullValueHandling = NV.Ignore)]
- public Journey Out { get; set; }
-
- [J("ret", NullValueHandling = NV.Ignore)]
- public Journey Ret { get; set; }
- }
-
- public class Journey {
- [J("txt", NullValueHandling = NV.Ignore)]
- public string Txt { get; set; }
-
- [J("@posnr", NullValueHandling = NV.Ignore)]
- public string Posnr { get; set; }
-
- [J("trainlist", NullValueHandling = NV.Ignore)]
- public Trainlist Trainlist { get; set; }
- }
-
- public class Trainlist {
- [J("train", NullValueHandling = NV.Ignore), JsonConverter(typeof(SingleOrArrayConverter))]
- public List Train { get; set; }
- }
-
- public class Train {
- [J("@tid", NullValueHandling = NV.Ignore)]
- public string Tid { get; set; }
-
- [J("@type", NullValueHandling = NV.Ignore)]
- public string Type { get; set; }
-
- [J("zugnr", NullValueHandling = NV.Ignore)]
- public string Zugnummer { get; set; }
-
- [J("arr", NullValueHandling = NV.Ignore)]
- public Station Arr { get; set; }
-
- [J("gat", NullValueHandling = NV.Ignore)]
- public string Gattung { get; set; }
-
- [J("sci", NullValueHandling = NV.Ignore)]
- public string Zugklasse { get; set; }
-
- [J("dep", NullValueHandling = NV.Ignore)]
- public Station Dep { get; set; }
-
- [J("@tn", NullValueHandling = NV.Ignore)]
- public string Line { get; set; }
- }
-
- public class Station {
- [J("x", NullValueHandling = NV.Ignore)]
- public string X { get; set; }
-
- [J("y", NullValueHandling = NV.Ignore)]
- public string Y { get; set; }
-
- [J("@dt", NullValueHandling = NV.Ignore)]
- public string Date { get; set; }
-
- [J("ebhf_name", NullValueHandling = NV.Ignore)]
- public string EbhfName { get; set; }
-
- [J("ebhf_nr", NullValueHandling = NV.Ignore)]
- public string EbhfNr { get; set; }
-
- [J("@t", NullValueHandling = NV.Ignore)]
- public string Time { get; set; }
-
- [J("n", NullValueHandling = NV.Ignore)]
- public string Name { get; set; }
-
- [J("nr", NullValueHandling = NV.Ignore)]
- public string BhfNr { get; set; }
-
- [J("plz", NullValueHandling = NV.Ignore)]
- public string Plz { get; set; }
-
- [J("ptf", NullValueHandling = NV.Ignore)]
- public string Ptf { get; set; }
- }
-
- public class Tcklist {
- [J("tck", NullValueHandling = NV.Ignore), JsonConverter(typeof(SingleOrArrayConverter))]
- public List Tck { get; set; }
- }
-
- public class Tck {
- [J("mtk", NullValueHandling = NV.Ignore)]
- public Mtk Mtk { get; set; }
-
- [J("@posnr", NullValueHandling = NV.Ignore)]
- public string Posnr { get; set; }
-
- [J("htdata", NullValueHandling = NV.Ignore)]
- public Htdata Htdata { get; set; }
- }
-
- public class Htdata {
- [J("ht", NullValueHandling = NV.Ignore)]
- public List Ht { get; set; }
- }
-
- public class Ht {
- [J("@pos", NullValueHandling = NV.Ignore)]
- public string Pos { get; set; }
-
- [J("#text", NullValueHandling = NV.Ignore)]
- public string Text { get; set; }
-
- [J("@name", NullValueHandling = NV.Ignore)]
- public string Name { get; set; }
-
- [J("@type", NullValueHandling = NV.Ignore)]
- public string Type { get; set; }
- }
-
- public class Mtk {
- [J("@status", NullValueHandling = NV.Ignore)]
- public string Status { get; set; }
-
- [J("@dir", NullValueHandling = NV.Ignore)]
- public string Dir { get; set; }
-
- [J("iss", NullValueHandling = NV.Ignore)]
- public string Iss { get; set; }
-
- [J("tkey", NullValueHandling = NV.Ignore)]
- public string Tkey { get; set; }
-
- [J("bc", NullValueHandling = NV.Ignore)]
- public Bc Bc { get; set; }
-
- [J("nvplist", NullValueHandling = NV.Ignore)]
- public Nvplist Nvplist { get; set; }
-
- [J("reisender_vorname", NullValueHandling = NV.Ignore)]
- public string ReisenderVorname { get; set; }
-
- [J("reisender_nachname", NullValueHandling = NV.Ignore)]
- public string ReisenderNachname { get; set; }
-
- [J("txt", NullValueHandling = NV.Ignore)]
- public string Txt { get; set; }
-
- [J("zb", NullValueHandling = NV.Ignore)]
- public string Zb { get; set; }
-
- [J("ot_nr_hin", NullValueHandling = NV.Ignore)]
- public string OtNrHin { get; set; }
- }
-
- public class Bc {
- [J("rbs", NullValueHandling = NV.Ignore)]
- public string Rbs { get; set; }
-
- [J("anz", NullValueHandling = NV.Ignore)]
- public string Anz { get; set; }
- }
-
- public class Rpheader {
- [J("@ts", NullValueHandling = NV.Ignore)]
- public string Ts { get; set; }
-
- [J("@tnr", NullValueHandling = NV.Ignore)]
- public string Tnr { get; set; }
- }
-
- public class Xml {
- [J("@version", NullValueHandling = NV.Ignore)]
- public string Version { get; set; }
-
- [J("@encoding", NullValueHandling = NV.Ignore)]
- public string Encoding { get; set; }
- }
-
- public partial class TicketResponse {
- public static TicketResponse FromJson(string json) => JsonConvert.DeserializeObject(json, Converter.Settings);
- }
-
- internal static class Converter {
- public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings {
- MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
- DateParseHandling = DateParseHandling.None,
- Converters = {new IsoDateTimeConverter {DateTimeStyles = DateTimeStyles.AssumeUniversal}}
- };
- }
-
- internal class SingleOrArrayConverter : JsonConverter {
- public override bool CanWrite => false;
-
- public override bool CanConvert(Type objectType) => objectType == typeof(List);
-
- public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
- var token = JToken.Load(reader);
- return token.Type == JTokenType.Array ? token.ToObject>() : new List {token.ToObject()};
- }
-
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/trainav.web/Migrations.cs b/trainav.web/Migrations.cs
index 66ec099..f47df02 100644
--- a/trainav.web/Migrations.cs
+++ b/trainav.web/Migrations.cs
@@ -9,7 +9,7 @@ using trainav.web.database.Tables;
namespace trainav.web;
public static class Migrations {
- private const int DbVer = 1;
+ private const int DbVer = 2;
private static readonly List _migrations = new() {
new Migration(1,
@@ -19,7 +19,28 @@ public static class Migrations {
new Migration(1,
"CREATE TABLE Tickets(\"TicketID\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, \"UserID\" INTEGER NOT NULL, \"OrderID\" TEXT NOT NULL UNIQUE, \"TicketInfo\" TEXT NOT NULL, \"TicketQR\" BLOB NOT NULL, \"TicketPkPass\" BLOB, \"TicketSecCode\" BLOB NOT NULL, \"Traveller\" TEXT)"),
new Migration(1, "INSERT INTO Tickets SELECT TicketID, UserID, OrderID, TicketInfo, TicketQR, TicketPkPass, TicketSecCode, Traveller FROM Tickets_backup"),
- new Migration(1, "DROP TABLE Tickets_backup")
+ new Migration(1, "DROP TABLE Tickets_backup"),
+ new Migration(2,
+ "CREATE TEMPORARY TABLE Legs_backup(\"LegID\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, \"TripID\" INTEGER NOT NULL, \"UserID\" INTEGER NOT NULL, \"TrainType\" TEXT NOT NULL, \"TrainNr\" INTEGER NOT NULL, \"DepStationID\" INTEGER NOT NULL, \"DepStation\" TEXT NOT NULL, \"DepTime\" TEXT NOT NULL, \"ArrStationID\" INTEGER NOT NULL, \"ArrStation\" TEXT NOT NULL, \"ArrTime\" TEXT NOT NULL, \"TicketID\" INTEGER, Comment TEXT)"),
+ new Migration(2,
+ "INSERT INTO Legs_backup SELECT LegID, TripID, UserID, TrainType, TrainNr, DepStationID, DepStation, DepTime, ArrStationID, ArrStation, ArrTime, TicketID, Comment FROM Legs"),
+ new Migration(2, "DROP Table Legs"),
+ new Migration(2,
+ "CREATE TABLE Legs(\"LegID\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, \"TripID\" INTEGER NOT NULL, \"UserID\" INTEGER NOT NULL, \"TrainType\" TEXT NOT NULL, \"TrainNr\" INTEGER NOT NULL, \"DepStationID\" INTEGER NOT NULL, \"DepStation\" TEXT NOT NULL, \"DepTime\" TEXT NOT NULL, \"ArrStationID\" INTEGER NOT NULL, \"ArrStation\" TEXT NOT NULL, \"ArrTime\" TEXT NOT NULL, Comment TEXT)"),
+ new Migration(2, "INSERT INTO Legs SELECT LegID, TripID, UserID, TrainType, TrainNr, DepStationID, DepStation, DepTime, ArrStationID, ArrStation, ArrTime, Comment FROM Legs_backup"),
+ new Migration(2,
+ "CREATE TEMPORARY TABLE Users_backup(\"UserID\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, \"Username\" TEXT NOT NULL UNIQUE, \"Password\" TEXT NOT NULL)"),
+ new Migration(2,
+ "INSERT INTO Users_backup SELECT UserID, Username, Password FROM Users"),
+ new Migration(2, "DROP Table Users"),
+ new Migration(2,
+ "CREATE TABLE Users(\"UserID\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, \"Username\" TEXT NOT NULL UNIQUE)"),
+ new Migration(2, "INSERT INTO Users SELECT UserID, Username FROM Users_backup"),
+ new Migration(2, "DROP TABLE Users_backup"),
+ new Migration(2, "DROP TABLE Legs_backup"),
+ new Migration(2, "DROP TABLE Tickets"),
+ new Migration(2, "DROP TABLE TicketLegs"),
+ new Migration(2, "DROP TABLE Cards")
};
public static void RunMigrations() {
@@ -33,10 +54,7 @@ public static class Migrations {
Console.WriteLine("Initialize Database");
db.CreateTable();
- db.CreateTable();
db.CreateTable();
- db.CreateTable();
- db.CreateTable();
db.CreateTable();
db.CreateTable();
@@ -102,4 +120,4 @@ public static class Migrations {
db.Execute(_sql);
}
}
-}
\ No newline at end of file
+}
diff --git a/trainav.web/Pages/Card.cshtml b/trainav.web/Pages/Card.cshtml
deleted file mode 100644
index b5f870d..0000000
--- a/trainav.web/Pages/Card.cshtml
+++ /dev/null
@@ -1,16 +0,0 @@
-@page
-@using Microsoft.AspNetCore.Http
-@using Microsoft.AspNetCore.Http.Extensions
-@model CardModel
-
-@{
- ViewData["Title"] = "Card";
- Response.Redirect("/Cards");
-
- if (HttpContext.Session.GetString("authorized") != "true") {
- Response.Redirect($"/Login?&redir={Request.GetDisplayUrl().UrlEncode()}");
- return;
- }
-}
-
-Card saved. Redirecting...
\ No newline at end of file
diff --git a/trainav.web/Pages/Card.cshtml.cs b/trainav.web/Pages/Card.cshtml.cs
deleted file mode 100644
index 37eb30d..0000000
--- a/trainav.web/Pages/Card.cshtml.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using System.Linq;
-using System.Net;
-using System.Xml;
-using System.Xml.Linq;
-using LinqToDB;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Newtonsoft.Json;
-using trainav.web.database;
-using trainav.web.database.Tables;
-using trainav.web.JSON.CardResponse;
-using trainav.web.JSON.ListOrdersResponse;
-
-namespace trainav.web.Pages;
-
-public class CardModel : PageModel {
- public void OnPost() {
- if (HttpContext.Session.GetString("authorized") != "true")
- return;
-
- using var db = new Database.DbConn();
- var request = new XDocument(new XElement("rqorderheadlist",
- new XElement("rqheader", new XAttribute("ts", "2020-02-19T15:59:00"), new XAttribute("l", "de"), new XAttribute("v", "19120000"),
- new XAttribute("d", "iPad7,5"), new XAttribute("os", "iOS_13.3.1"), new XAttribute("app", "NAVIGATOR")),
- new XElement("authlogin", new XAttribute("user", Request.Form["user"]), new XAttribute("pw", Request.Form["pass"]),
- new XElement("sso", new XAttribute("genToken", "FALSE"))),
- new XElement("criteria", new XAttribute("validonly", "0")))).ToString();
- var response = new WebClient().UploadString("https://fahrkarten.bahn.de/mobile/dbc/xs.go", "POST", request);
- var xmlobj = new XmlDocument();
- xmlobj.LoadXml(response);
- var json = JsonConvert.SerializeXmlNode(xmlobj);
- var parsed = ListOrdersResponse.FromJson(json);
-
- foreach (var order in parsed.Rporderheadlist.Orderheadlist.Orderhead.Where(order => order.On.StartsWith("EBC_"))) {
- request = new XDocument(new XElement("rqorderdetails", new XAttribute("version", "1.0"),
- new XElement("rqheader", new XAttribute("ts", "2019-10-31T23:20:48"), new XAttribute("l", "de"), new XAttribute("v", "19100000"),
- new XAttribute("d", "iPad7,5"), new XAttribute("os", "iOS_13.1.3"), new XAttribute("app", "NAVIGATOR")),
- new XElement("rqorder", new XAttribute("on", order.On)), new XElement("authname", new XAttribute("tln", Request.Form["name"]))))
- .ToString();
-
- response = new WebClient().UploadString("https://fahrkarten.bahn.de/mobile/dbc/xs.go", "POST", request);
- xmlobj = new XmlDocument();
- xmlobj.LoadXml(response);
- json = JsonConvert.SerializeXmlNode(xmlobj);
- var parsedCard = CardResponse.FromJson(json);
-
- db.InsertWithInt32Identity(new Card {
- OrderId = order.On,
- UserId = int.Parse(HttpContext.Session.GetString("uid")),
- Class = int.Parse(parsedCard.Rporderdetails.Order.Tcklist.Tck.Mtk.Nvplist.Nvp.First(p => p.Name == "klasse").Text),
- Value = int.Parse(parsedCard.Rporderdetails.Order.Tcklist.Tck.Mtk.Nvplist.Nvp.First(p => p.Name == "rbs").Text),
- CardNumber = parsedCard.Rporderdetails.Order.Tcklist.Tck.Mtk.Nvplist.Nvp.First(p => p.Name == "bcnummer").Text,
- CardInfo = parsedCard.Rporderdetails.Order.Tcklist.Tck.Mtk.Txt,
- CardQr = parsedCard.Rporderdetails.Order.Tcklist.Tck.Htdata.Ht.First(p => p.Name == "barcode").Text,
- CardSecCode = parsedCard.Rporderdetails.Order.Tcklist.Tck.Htdata.Ht.First(p => p.Name == "sichtmerkmal").Text,
- CardImage = parsedCard.Rporderdetails.Order.Tcklist.Tck.Bahncardimage.CdataSection,
- Traveller = parsedCard.Rporderdetails.Order.Tcklist.Tck.Mtk.Nvplist.Nvp.First(p => p.Name == "inhaber").Text,
- ValidFrom = parsedCard.Rporderdetails.Order.Vfrom,
- ValidTo = parsedCard.Rporderdetails.Order.Vto,
- QrValidFrom = parsedCard.Rporderdetails.Order.Tcklist.Tck.Mtk.Nvplist.Nvp.First(p => p.Name == "ebcbarcodegueltigab").Text,
- QrValidTo = parsedCard.Rporderdetails.Order.Tcklist.Tck.Mtk.Nvplist.Nvp.First(p => p.Name == "ebcbarcodegueltigbis").Text
- });
- }
- }
-}
\ No newline at end of file
diff --git a/trainav.web/Pages/Cards.cshtml b/trainav.web/Pages/Cards.cshtml
deleted file mode 100644
index 3641ec8..0000000
--- a/trainav.web/Pages/Cards.cshtml
+++ /dev/null
@@ -1,169 +0,0 @@
-@page
-@using Microsoft.AspNetCore.Http
-@using Microsoft.AspNetCore.Http.Extensions
-@using System.Text
-@model CardsModel
-@{
- ViewData["Title"] = "Cards";
-
- if (HttpContext.Session.GetString("authorized") != "true") {
- Response.Redirect($"/Login?&redir={Request.GetDisplayUrl().UrlEncode()}");
- return;
- }
-
- if (Request.Query.ContainsKey("refresh")) {
- Response.Redirect("?edit=true");
- return;
- }
-}
-
-@if (Request.Query["edit"] == "true") {
-
-
-
- Card
- Number
- Traveller
- Card Validity
- QR Validity
- Actions
-
-
-
- @foreach (var card in Model.Cards) {
-
- @card.CardInfo.TrimEnd('#')
- @card.CardNumber
- @card.Traveller
-
- @{
- var from = DateTime.Parse(card.ValidFrom);
- var to = DateTime.Parse(card.ValidTo);
- if (from > DateTime.Now) {
-
- @card.ValidFrom.Split("T")[0]
-
- }
- else {
- @card.ValidFrom.Split("T")[0]
- }
-
- if (to < DateTime.Now) {
-
- @card.ValidTo.Split("T")[0]
-
- }
- else {
- @card.ValidTo.Split("T")[0]
- }
- }
-
-
- @{
- var qrfrom = DateTime.Parse(card.QrValidFrom);
- var qrto = DateTime.Parse(card.QrValidTo);
- if (qrfrom > DateTime.Now) {
-
- @card.QrValidFrom.Split("T")[0]
-
- }
- else {
- @card.QrValidFrom.Split("T")[0]
- }
-
- if (qrto < DateTime.Now) {
-
- @card.QrValidTo.Split("T")[0]
-
- }
- else {
- @card.QrValidTo.Split("T")[0]
- }
- }
-
-
- Refresh QR
- Delete
-
-
- }
-
-
-
- Please refresh your BahnCard list in the mobile DB Navigator before clicking "Refresh QR". This will be fixed in a later release.
-
- Back
-
-
-
-}
-else if (Model.Cards.Any()) {
- foreach (var card in Model.Cards) {
- if (!card.CardQr.StartsWith("data:image/png"))
- card.CardQr = Encoding.UTF8.GetString(Convert.FromBase64String(card.CardQr));
- if (!card.CardSecCode.StartsWith("data:image/png"))
- card.CardSecCode = Encoding.UTF8.GetString(Convert.FromBase64String(card.CardSecCode));
- if (!card.CardImage.StartsWith("
-
-
-
-
-
-
-
-
-
-
-
-
- var from = DateTime.Parse(card.ValidFrom);
- var to = DateTime.Parse(card.ValidTo);
- var qrfrom = DateTime.Parse(card.QrValidFrom);
- var qrto = DateTime.Parse(card.QrValidTo);
-
- if (from > DateTime.Now) {
-
- The above card is not valid yet.
-
- }
- if (to < DateTime.Now) {
-
- The above card is expired.
-
- }
- if (qrfrom > DateTime.Now && !(from > DateTime.Now)) {
-
- The above QR code is somehow not valid yet. Congrats, please open a bug report.
-
- }
- if (qrto < DateTime.Now) {
-
- }
-
- }
-
- Edit cards
-}
-
-@if (!Model.Cards.Any() || Request.Query["edit"] == "true") {
- Get Cards from bahn.de account
-
-
-}
diff --git a/trainav.web/Pages/Cards.cshtml.cs b/trainav.web/Pages/Cards.cshtml.cs
deleted file mode 100644
index fc74f36..0000000
--- a/trainav.web/Pages/Cards.cshtml.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Xml;
-using System.Xml.Linq;
-using LinqToDB;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Newtonsoft.Json;
-using trainav.web.database;
-using trainav.web.database.Tables;
-using trainav.web.JSON.CardResponse;
-
-namespace trainav.web.Pages;
-
-public class CardsModel : PageModel {
- public List Cards;
-
- public void OnGet() {
- if (HttpContext.Session.GetString("authorized") != "true")
- return;
-
- using var db = new Database.DbConn();
-
- if (Request.Query.ContainsKey("refresh")) {
- var card = db.Cards.First(p => p.CardId == int.Parse(Request.Query["refresh"]));
- if (card.UserId != int.Parse(HttpContext.Session.GetString("uid")))
- return;
-
- var request = new XDocument(new XElement("rqorderdetails", new XAttribute("version", "1.0"),
- new XElement("rqheader", new XAttribute("ts", "2019-10-31T23:20:48"), new XAttribute("l", "de"),
- new XAttribute("v", "19100000"), new XAttribute("d", "iPad7,5"), new XAttribute("os", "iOS_13.1.3"),
- new XAttribute("app", "NAVIGATOR")), new XElement("rqorder", new XAttribute("on", card.OrderId)),
- new XElement("authname", new XAttribute("tln", card.Traveller.Split(" ").Last())))).ToString();
-
- var response = new WebClient().UploadString("https://fahrkarten.bahn.de/mobile/dbc/xs.go", "POST", request);
- var xmlobj = new XmlDocument();
- xmlobj.LoadXml(response);
- var json = JsonConvert.SerializeXmlNode(xmlobj);
- var parsedCard = CardResponse.FromJson(json);
-
- card.CardQr = parsedCard.Rporderdetails.Order.Tcklist.Tck.Htdata.Ht.First(p => p.Name == "barcode").Text;
- card.CardSecCode = parsedCard.Rporderdetails.Order.Tcklist.Tck.Htdata.Ht.First(p => p.Name == "sichtmerkmal").Text;
- card.CardImage = parsedCard.Rporderdetails.Order.Tcklist.Tck.Bahncardimage.CdataSection;
- card.QrValidFrom = parsedCard.Rporderdetails.Order.Tcklist.Tck.Mtk.Nvplist.Nvp.First(p => p.Name == "ebcbarcodegueltigab").Text;
- card.QrValidTo = parsedCard.Rporderdetails.Order.Tcklist.Tck.Mtk.Nvplist.Nvp.First(p => p.Name == "ebcbarcodegueltigbis").Text;
-
- db.Update(card);
- return;
- }
-
- Cards = db.Cards.Where(p => p.UserId == int.Parse(HttpContext.Session.GetString("uid"))).ToList();
- }
-}
\ No newline at end of file
diff --git a/trainav.web/Pages/Delete.cshtml b/trainav.web/Pages/Delete.cshtml
index 8cd0455..3f7ef94 100644
--- a/trainav.web/Pages/Delete.cshtml
+++ b/trainav.web/Pages/Delete.cshtml
@@ -2,68 +2,50 @@
@using Microsoft.AspNetCore.Http
@using Microsoft.AspNetCore.Http.Extensions
@using trainav.web.database
+@using trainav.web.Utils
@model DeleteModel
@{
- ViewData["Title"] = "Home";
+ ViewData["Title"] = "Home";
+
+ if (Request.Query.ContainsKey("confirm") && Request.Query["confirm"] == "true") {
+ Layout = null;
- if (HttpContext.Session.GetString("authorized") != "true") {
- Response.Redirect($"/Login?&redir={Request.GetDisplayUrl().UrlEncode()}");
- return;
- }
+ if (Request.Query.ContainsKey("redir")) {
+ Response.Redirect(Request.Query["redir"]);
+ }
+ else {
+ Response.Redirect("/");
+ }
- if (Request.Query.ContainsKey("confirm") && Request.Query["confirm"] == "true") {
- Layout = null;
+ return;
+ }
- if (Request.Query.ContainsKey("redir")) {
- Response.Redirect(Request.Query["redir"]);
- }
- else {
- Response.Redirect("/");
- }
+ Are you sure?
+
+ You are attempting to delete
+ @{
+ await using var db = new Database.DbConn();
- return;
- }
+ switch (Request.Query["item"]) {
+ case "trip": {
+ var trip = db.Trips.First(p => p.TripId == int.Parse(Request.Query["id"]));
+ if (trip.UserId != Model.AuthorizedUser.UserId) {
+ return;
+ }
+ var legs = db.Legs.Where(p => p.TripId == int.Parse(Request.Query["id"])).OrderBy(p => p.DepTime).ToList();
-
Are you sure?
-
- You are attempting to delete
- @{
- await using var db = new Database.DbConn();
-
- switch (Request.Query["item"]) {
- case "trip": {
- var trip = db.Trips.First(p => p.TripId == int.Parse(Request.Query["id"]));
- if (trip.UserId != int.Parse(HttpContext.Session.GetString("uid"))) {
- return;
- }
- var legs = db.Legs.Where(p => p.TripId == int.Parse(Request.Query["id"])).OrderBy(p => p.DepTime).ToList();
-
-
- the trip from @legs.First().DepStation to @legs.Last().ArrStation , starting @legs.First().DepTime
-
- break;
- }
- case "leg": {
- Response.Redirect($"/Delete?item={Request.Query["item"]}&id={Request.Query["id"]}&confirm=true&redir={Request.Query["redir"].ToString().UrlEncode()}");
- break;
- }
- case "ticket": {
- Response.Redirect($"/Delete?item={Request.Query["item"]}&id={Request.Query["id"]}&confirm=true&redir={Request.Query["redir"].ToString().UrlEncode()}");
- break;
- }
- case "card": {
- var card = db.Cards.First(p => p.CardId == int.Parse(Request.Query["id"]));
- if (card.UserId != int.Parse(HttpContext.Session.GetString("uid"))) {
- return;
- }
-
- the card @card.CardInfo.TrimEnd('#') with the number @card.CardNumber , owned by @card.Traveller
-
- break;
- }
- }
- }
-
- Cancel
- Confirm
-}
\ No newline at end of file
+
+ the trip from @legs.First().DepStation to @legs.Last().ArrStation , starting @legs.First().DepTime
+
+ break;
+ }
+ case "leg": {
+ Response.Redirect($"/Delete?item={Request.Query["item"]}&id={Request.Query["id"]}&confirm=true&redir={Request.Query["redir"].ToString().UrlEncode()}");
+ break;
+ }
+ }
+ }
+
+ Cancel
+ Confirm
+}
diff --git a/trainav.web/Pages/Delete.cshtml.cs b/trainav.web/Pages/Delete.cshtml.cs
index 632eda1..892bcf6 100644
--- a/trainav.web/Pages/Delete.cshtml.cs
+++ b/trainav.web/Pages/Delete.cshtml.cs
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.RazorPages;
using trainav.web.database;
using trainav.web.database.Tables;
+using trainav.web.Utils;
namespace trainav.web.Pages;
@@ -11,21 +12,17 @@ public class DeleteModel : PageModel {
public User AuthorizedUser;
public void OnGet() {
- if (HttpContext.Session.GetString("authorized") != "true")
- return;
-
if (!Request.Query.ContainsKey("confirm") || Request.Query["confirm"] != "true")
return;
- var uid = int.Parse(HttpContext.Session.GetString("uid"));
using var db = new Database.DbConn();
- AuthorizedUser = db.Users.FirstOrDefault(p => p.UserId == uid);
+ AuthorizedUser = db.Users.FirstOrDefault(p => p.Username == AuthUtil.GetRemoteUser(HttpContext, db));
var id = int.Parse(Request.Query["id"]);
switch (Request.Query["item"]) {
case "trip": {
var trip = db.Trips.First(p => p.TripId == id);
- if (trip.UserId != int.Parse(HttpContext.Session.GetString("uid")))
+ if (trip.UserId != AuthorizedUser!.UserId)
return;
db.Trips.Delete(p => p.TripId == id);
@@ -34,7 +31,7 @@ public class DeleteModel : PageModel {
}
case "leg": {
var leg = db.Legs.First(p => p.LegId == id);
- if (leg.UserId != int.Parse(HttpContext.Session.GetString("uid")))
+ if (leg.UserId != AuthorizedUser!.UserId)
return;
var tripid = db.Legs.First(p => p.LegId == id).TripId;
@@ -62,22 +59,6 @@ public class DeleteModel : PageModel {
break;
}
- case "ticket": {
- var leg = db.Legs.First(p => p.LegId == id);
- if (leg.UserId != int.Parse(HttpContext.Session.GetString("uid")))
- return;
-
- db.Legs.Where(p => p.LegId == id).Set(p => p.TicketId, 0).Update();
- break;
- }
- case "card": {
- var card = db.Cards.First(p => p.CardId == id);
- if (card.UserId != int.Parse(HttpContext.Session.GetString("uid")))
- return;
-
- db.Cards.Delete(p => p.CardId == id);
- break;
- }
}
}
-}
\ No newline at end of file
+}
diff --git a/trainav.web/Pages/Index.cshtml b/trainav.web/Pages/Index.cshtml
index 35b7e33..2f90e79 100644
--- a/trainav.web/Pages/Index.cshtml
+++ b/trainav.web/Pages/Index.cshtml
@@ -1,101 +1,97 @@
@page
+@using LinqToDB
@using Microsoft.AspNetCore.Http
@using Microsoft.AspNetCore.Http.Extensions
-@using LinqToDB
+@using Microsoft.AspNetCore.Mvc.TagHelpers
+@using trainav.web.Utils
@using trainav.web.database
@model IndexModel
@{
- ViewData["Title"] = "Home";
+ ViewData["Title"] = "Home";
}
- @if (HttpContext.Session.GetString("authorized") != "true") {
-
Welcome
-
Please log in to see your personal plan.
- }
- else {
-
- Welcome, @Model.AuthorizedUser.Username
-
-
- Here are your planned trips.
-
-
-
-
- Origin
- Via
- Destination
- Comments
- Actions
-
-
-
- @{
- await using var db = new Database.DbConn();
- var trips = db.Trips.Where(p => p.UserId == Model.AuthorizedUser.UserId).ToList();
+
+ Welcome, @Model.AuthorizedUser.Username
+
+
+ Here are your planned trips.
+
+
+
+
+ Origin
+ Via
+ Destination
+ Comments
+ Actions
+
+
+
+ @{
+ await using var db = new Database.DbConn();
+ var trips = db.Trips.Where(p => p.UserId == Model.AuthorizedUser.UserId).ToList();
- foreach (var trip in trips.Where(trip => !db.Legs.Any(p => p.TripId == trip.TripId))) {
- await db.DeleteAsync(trip);
- trips = db.Trips.Where(p => p.UserId == Model.AuthorizedUser.UserId).ToList();
- }
+ foreach (var trip in trips.Where(trip => !db.Legs.Any(p => p.TripId == trip.TripId))) {
+ await db.DeleteAsync(trip);
+ trips = db.Trips.Where(p => p.UserId == Model.AuthorizedUser.UserId).ToList();
+ }
- foreach (var trip in trips.OrderBy(p => db.Legs.Where(a => a.TripId == p.TripId).OrderBy(leg => leg.DepTime).First().DepTime)) {
- var legs = db.Legs.Where(p => p.TripId == trip.TripId).OrderBy(p => p.DepTime).ToList();
-
-
- @legs.First().DepStation.Delimit(30)
-
- @DateTime.Parse(legs.First().DepTime).ToString("ddd dd.MM.yyyy, HH:mm")
-
-
- @((from index in from leg in legs where leg.TrainType == "placeholder" select legs.IndexOf(leg) select legs[index - 1].ArrStation.Delimit(30)).ToList().DefaultIfEmpty("-").Aggregate((s1, s2) => $"{s1}, {s2}"))
-
-
- @legs.Last().ArrStation.Delimit(30)
-
- @DateTime.Parse(legs.Last().ArrTime).ToString("ddd dd.MM.yyyy, HH:mm")
-
-
- @Html.Raw(legs.Where(leg => !string.IsNullOrWhiteSpace(leg.Comment)).Select(p => p.Comment.Replace(", ", " ")).DefaultIfEmpty("").Aggregate((s1, s2) => $"{s1} {s2}"))
-
-
- View
-
- Delete
-
-
- }
- }
-
-
-
-
- }
+ foreach (var trip in trips.OrderBy(p => db.Legs.Where(a => a.TripId == p.TripId).OrderBy(leg => leg.DepTime).First().DepTime)) {
+ var legs = db.Legs.Where(p => p.TripId == trip.TripId).OrderBy(p => p.DepTime).ToList();
+
+
+ @legs.First().DepStation.Delimit(30)
+
+ @DateTime.Parse(legs.First().DepTime).ToString("ddd dd.MM.yyyy, HH:mm")
+
+
+ @((from index in from leg in legs where leg.TrainType == "placeholder" select legs.IndexOf(leg) select legs[index - 1].ArrStation.Delimit(30)).ToList().DefaultIfEmpty("-").Aggregate((s1, s2) => $"{s1}, {s2}"))
+
+
+ @legs.Last().ArrStation.Delimit(30)
+
+ @DateTime.Parse(legs.Last().ArrTime).ToString("ddd dd.MM.yyyy, HH:mm")
+
+
+ @Html.Raw(legs.Where(leg => !string.IsNullOrWhiteSpace(leg.Comment)).Select(p => p.Comment.Replace(", ", " ")).DefaultIfEmpty("").Aggregate((s1, s2) => $"{s1} {s2}"))
+
+
+ View
+
+ Delete
+
+
+ }
+ }
+
+
+
+
diff --git a/trainav.web/Pages/Index.cshtml.cs b/trainav.web/Pages/Index.cshtml.cs
index 43b7c09..9073aba 100644
--- a/trainav.web/Pages/Index.cshtml.cs
+++ b/trainav.web/Pages/Index.cshtml.cs
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.RazorPages;
using trainav.web.database;
using trainav.web.database.Tables;
+using trainav.web.Utils;
namespace trainav.web.Pages;
@@ -10,11 +11,7 @@ public class IndexModel : PageModel {
public User AuthorizedUser;
public void OnGet() {
- if (HttpContext.Session.GetString("authorized") != "true")
- return;
-
- var uid = int.Parse(HttpContext.Session.GetString("uid"));
using var db = new Database.DbConn();
- AuthorizedUser = db.Users.FirstOrDefault(p => p.UserId == uid);
+ AuthorizedUser = db.Users.FirstOrDefault(p => p.Username == AuthUtil.GetRemoteUser(HttpContext, db));
}
-}
\ No newline at end of file
+}
diff --git a/trainav.web/Pages/Inspection.cshtml b/trainav.web/Pages/Inspection.cshtml
deleted file mode 100644
index 4be46f1..0000000
--- a/trainav.web/Pages/Inspection.cshtml
+++ /dev/null
@@ -1,151 +0,0 @@
-@page
-@using Microsoft.AspNetCore.Http
-@using Microsoft.AspNetCore.Http.Extensions
-@using trainav.web.database
-@using System.Text
-@model InspectionModel
-@{
- ViewData["Title"] = "Inspection";
-
- if (HttpContext.Session.GetString("authorized") != "true") {
- Response.Redirect($"/Login?&redir={Request.GetDisplayUrl().UrlEncode()}");
- return;
- }
-
- if (Model.Leg.UserId != int.Parse(HttpContext.Session.GetString("uid"))) {
- return;
- }
-}
-
-
- Ticket for @Model.Leg.TrainType @Model.Leg.TrainNr from @Model.Leg.DepStation to @Model.Leg.ArrStation , starting @DateTime.Parse(Model.Leg.DepTime).ToString("yyyy-MM-dd HH:mm")
-
-
-
-
-
-
-
-
-
-
-
-@Model.Ticket.TicketInfo
-
-
-@if (Model.Ticket.TicketInfo.Contains("BC 50")) {
- await using var db = new Database.DbConn();
- if (db.Cards.Any(p => p.Value == 50 && p.Traveller == Model.Ticket.Traveller && p.UserId == Model.Leg.UserId)) {
- var card = db.Cards.First(p => p.Value == 50 && p.Traveller == Model.Ticket.Traveller && p.UserId == Model.Leg.UserId);
-
- if (!card.CardQr.StartsWith("data:image/png"))
- card.CardQr = Encoding.UTF8.GetString(Convert.FromBase64String(card.CardQr));
- if (!card.CardSecCode.StartsWith("data:image/png"))
- card.CardSecCode = Encoding.UTF8.GetString(Convert.FromBase64String(card.CardSecCode));
- if (!card.CardImage.StartsWith("
-
-
-
-
-
-
-
-
-
-
-
-
-
- var from = DateTime.Parse(card.ValidFrom);
- var to = DateTime.Parse(card.ValidTo);
- var qrfrom = DateTime.Parse(card.QrValidFrom);
- var qrto = DateTime.Parse(card.QrValidTo);
-
- if (from > DateTime.Now) {
-
- The above card is not valid yet.
-
- }
- if (to < DateTime.Now) {
-
- The above card is expired.
-
- }
- if (qrfrom > DateTime.Now && !(from > DateTime.Now)) {
-
- The above QR code is somehow not valid yet. Congrats, please open a bug report.
-
- }
- if (qrto < DateTime.Now) {
-
- }
- }
- else {
-
- I would show your BahnCard but you haven't added a card matching the value and name of the ticket yet.
You can do that now .
-
- }
-}
-else if (Model.Ticket.TicketInfo.Contains("BC 25")) {
- await using var db = new Database.DbConn();
- if (db.Cards.Any(p => p.Value == 25 && p.Traveller == Model.Ticket.Traveller && p.UserId == Model.Leg.UserId)) {
- var card = db.Cards.First(p => p.Value == 25 && p.Traveller == Model.Ticket.Traveller && p.UserId == Model.Leg.UserId);
-
- if (!card.CardQr.StartsWith("data:image/png"))
- card.CardQr = Encoding.UTF8.GetString(Convert.FromBase64String(card.CardQr));
- if (!card.CardSecCode.StartsWith("data:image/png"))
- card.CardSecCode = Encoding.UTF8.GetString(Convert.FromBase64String(card.CardSecCode));
- if (!card.CardImage.StartsWith("
-
-
-
-
-
-
-
-
-
-
-
-
-
- var from = DateTime.Parse(card.ValidFrom);
- var to = DateTime.Parse(card.ValidTo);
- var qrfrom = DateTime.Parse(card.QrValidFrom);
- var qrto = DateTime.Parse(card.QrValidTo);
-
- if (from > DateTime.Now) {
-
- The above card is not valid yet.
-
- }
- if (to < DateTime.Now) {
-
- The above card is expired.
-
- }
- if (qrfrom > DateTime.Now && !(from > DateTime.Now)) {
-
- The above QR code is somehow not valid yet. Congrats, please open a bug report.
-
- }
- if (qrto < DateTime.Now) {
-
- }
- }
- else {
-
- I would show your BahnCard but you haven't added a card matching the value and name of the ticket yet.
You can do that now .
-
- }
-}
diff --git a/trainav.web/Pages/Inspection.cshtml.cs b/trainav.web/Pages/Inspection.cshtml.cs
deleted file mode 100644
index b857253..0000000
--- a/trainav.web/Pages/Inspection.cshtml.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-using System.Linq;
-using System.Text;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using trainav.web.database;
-using trainav.web.database.Tables;
-
-namespace trainav.web.Pages;
-
-public class InspectionModel : PageModel {
- public Leg Leg;
- public Ticket Ticket;
-
- public void OnGet() {
- if (HttpContext.Session.GetString("authorized") != "true")
- return;
-
- using var db = new Database.DbConn();
- Leg = db.Legs.First(p => p.LegId == int.Parse(Request.Query["leg"]));
- Ticket = db.Tickets.First(p => p.TicketId == Leg.TicketId);
-
- if (!Ticket.TicketQr.StartsWith("data:image/png"))
- Ticket.TicketQr = Encoding.UTF8.GetString(Convert.FromBase64String(Ticket.TicketQr));
-
- if (!Ticket.TicketSecCode.StartsWith("data:image/png"))
- Ticket.TicketSecCode = Encoding.UTF8.GetString(Convert.FromBase64String(Ticket.TicketSecCode));
- }
-}
\ No newline at end of file
diff --git a/trainav.web/Pages/Login.cshtml b/trainav.web/Pages/Login.cshtml
deleted file mode 100644
index 2b7267e..0000000
--- a/trainav.web/Pages/Login.cshtml
+++ /dev/null
@@ -1,30 +0,0 @@
-@page
-@using Microsoft.AspNetCore.Http
-@model LoginModel
-
-@{
- ViewData["Title"] = "Login";
- if (HttpContext.Session.GetString("authorized") == "true") {
- if (Request.Query.ContainsKey("redir")) {
- Response.Redirect(Request.Query["redir"]);
- }
- else {
- Response.Redirect("/");
- }
- return;
- }
-}
-
-@ViewData["Title"]
-
-
\ No newline at end of file
diff --git a/trainav.web/Pages/Logout.cshtml b/trainav.web/Pages/Logout.cshtml
deleted file mode 100644
index e3147e1..0000000
--- a/trainav.web/Pages/Logout.cshtml
+++ /dev/null
@@ -1,7 +0,0 @@
-@page
-@model LogoutModel
-
-@{
- Layout = null;
- Response.Redirect("/");
-}
\ No newline at end of file
diff --git a/trainav.web/Pages/Logout.cshtml.cs b/trainav.web/Pages/Logout.cshtml.cs
deleted file mode 100644
index f5c6cc2..0000000
--- a/trainav.web/Pages/Logout.cshtml.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using Microsoft.AspNetCore.Mvc.RazorPages;
-
-namespace trainav.web.Pages;
-
-public class LogoutModel : PageModel {
- public void OnGet() {
- HttpContext.Session.Clear();
- }
-}
\ No newline at end of file
diff --git a/trainav.web/Pages/OEAPI.cshtml b/trainav.web/Pages/OEAPI.cshtml
index b13f3b6..e2979ac 100644
--- a/trainav.web/Pages/OEAPI.cshtml
+++ b/trainav.web/Pages/OEAPI.cshtml
@@ -1,16 +1,12 @@
@page
@using Microsoft.AspNetCore.Http
@using Microsoft.AspNetCore.Http.Extensions
+@using trainav.web.Utils
@model OEAPIModel
@{
- ViewData["Title"] = "OEAPI";
+ ViewData["Title"] = "OEAPI";
- if (HttpContext.Session.GetString("authorized") != "true") {
- Response.Redirect($"/Login?&redir={Request.GetDisplayUrl().UrlEncode()}");
- return;
- }
-
- Response.Redirect("/Trip?id=" + Model.TripId + "&edit=true");
+ Response.Redirect("/Trip?id=" + Model.TripId + "&edit=true");
}
-Trip saved. Redirecting...
\ No newline at end of file
+Trip saved. Redirecting...
diff --git a/trainav.web/Pages/OEAPI.cshtml.cs b/trainav.web/Pages/OEAPI.cshtml.cs
index 990d72d..69159fb 100644
--- a/trainav.web/Pages/OEAPI.cshtml.cs
+++ b/trainav.web/Pages/OEAPI.cshtml.cs
@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using trainav.web.database;
using trainav.web.database.Tables;
using trainav.web.JSON;
+using trainav.web.Utils;
using Leg = trainav.web.database.Tables.Leg;
// ReSharper disable PossibleInvalidOperationException
@@ -18,9 +19,6 @@ public class OEAPIModel : PageModel {
public int TripId;
public void OnGet() {
- if (HttpContext.Session.GetString("authorized") != "true")
- return;
-
var link = Request.Query["link"].ToString();
var shortcode = link;
var oepage = "oeffisear.ch";
@@ -40,13 +38,15 @@ public class OEAPIModel : PageModel {
var parsed = OeapiResponse.FromJson(response);
+ var authorizedUser = db.Users.FirstOrDefault(p => p.Username == AuthUtil.GetRemoteUser(HttpContext, db));
+
if (!string.IsNullOrWhiteSpace(Request.Query["tripid"].ToString()))
- if (db.Trips.First(p => p.TripId == int.Parse(Request.Query["tripid"].ToString())).UserId != int.Parse(HttpContext.Session.GetString("uid")))
+ if (db.Trips.First(p => p.TripId == int.Parse(Request.Query["tripid"].ToString())).UserId != authorizedUser!.UserId)
return;
var tripId = Request.Query["action"] == "addleg"
? int.Parse(Request.Query["tripid"])
- : db.InsertWithInt32Identity(new Trip { UserId = int.Parse(HttpContext.Session.GetString("uid")) });
+ : db.InsertWithInt32Identity(new Trip { UserId = authorizedUser!.UserId });
foreach (var journey in parsed.Data.Journeys[jid].Legs.Where(p => p.IsTransfer != true && p.IsWalking != true)) {
var arrtime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
@@ -62,7 +62,7 @@ public class OEAPIModel : PageModel {
db.InsertWithInt32Identity(new Leg {
TripId = tripId,
- UserId = int.Parse(HttpContext.Session.GetString("uid")),
+ UserId = authorizedUser!.UserId,
TrainType = journey.Line.ProductName,
TrainNr = trainNo,
ArrStation = journey.Arrival.Point.Stop.Name,
@@ -76,4 +76,4 @@ public class OEAPIModel : PageModel {
TripId = tripId;
}
-}
\ No newline at end of file
+}
diff --git a/trainav.web/Pages/Plain.cshtml b/trainav.web/Pages/Plain.cshtml
deleted file mode 100644
index db46bda..0000000
--- a/trainav.web/Pages/Plain.cshtml
+++ /dev/null
@@ -1,44 +0,0 @@
-@page
-@using Microsoft.AspNetCore.Http
-@using Microsoft.AspNetCore.Http.Extensions
-@using trainav.web.database
-@model PlainModel
-@{
- ViewData["Title"] = "Plain";
-
- if (HttpContext.Session.GetString("authorized") != "true") {
- Response.Redirect($"/Login?&redir={Request.GetDisplayUrl().UrlEncode()}");
- return;
- }
- await using var db = new Database.DbConn();
-}
-
-
-
- @foreach (var trip in db.Trips.Where(p => p.UserId == Model.AuthorizedUser.UserId).ToList().OrderBy(p => db.Legs.Where(l => l.TripId == p.TripId).OrderBy(l => l.DepTime).First().DepTime)) {
-
-
-
- foreach (var leg in db.Legs.Where(p => p.TripId == trip.TripId).OrderBy(p => p.DepTime)) {
- if (leg.TrainType == "placeholder") {
-
- ... ... ..:.. ... - ... ... - ..:.. ... ...
-
- continue;
- }
- var deptime = DateTime.Parse(leg.DepTime);
- var arrtime = DateTime.Parse(leg.ArrTime);
- var date = DateTime.Parse(leg.DepTime).ToString("ddd dd.MM.");
- var dept = date + " " + deptime.ToString("HH:mm");
- var depst = leg.DepStation.PadRight(20, ' ').Substring(0, 20).Replace(" ", " ");
- var arrt = arrtime.ToString("HH:mm");
- var arrst = leg.ArrStation.PadRight(20, ' ').Substring(0, 20).Replace(" ", " ");
- var line = leg.TrainType.PadRight(3).Replace(" ", " ") + " " + leg.TrainNr.ToString().PadRight(6).Replace(" ", " ");
- var comment = leg.Comment;
-
- @dept @Html.Raw(depst) - @Html.Raw(line) - @arrt @Html.Raw(arrst) @(string.IsNullOrWhiteSpace(comment) ? "..." : comment)
-
- }
- }
-
-
\ No newline at end of file
diff --git a/trainav.web/Pages/Plain.cshtml.cs b/trainav.web/Pages/Plain.cshtml.cs
deleted file mode 100644
index 5e167e2..0000000
--- a/trainav.web/Pages/Plain.cshtml.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.Linq;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using trainav.web.database;
-using trainav.web.database.Tables;
-
-namespace trainav.web.Pages;
-
-public class PlainModel : PageModel {
- public User AuthorizedUser;
-
- public void OnGet() {
- if (HttpContext.Session.GetString("authorized") != "true")
- return;
-
- var uid = int.Parse(HttpContext.Session.GetString("uid"));
- using var db = new Database.DbConn();
- AuthorizedUser = db.Users.FirstOrDefault(p => p.UserId == uid);
- }
-}
\ No newline at end of file
diff --git a/trainav.web/Pages/Register.cshtml b/trainav.web/Pages/Register.cshtml
deleted file mode 100644
index 75d6891..0000000
--- a/trainav.web/Pages/Register.cshtml
+++ /dev/null
@@ -1,29 +0,0 @@
-@page
-@using Microsoft.AspNetCore.Http
-@model RegisterModel
-
-@{
- ViewData["Title"] = "Register";
- if (HttpContext.Session.GetString("authorized") == "true") {
- Response.Redirect("/");
- return;
- }
-}
-
-@ViewData["Title"]
-
-
\ No newline at end of file
diff --git a/trainav.web/Pages/Register.cshtml.cs b/trainav.web/Pages/Register.cshtml.cs
deleted file mode 100644
index b188eca..0000000
--- a/trainav.web/Pages/Register.cshtml.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System.Linq;
-using LinqToDB;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using trainav.web.database;
-using trainav.web.database.Tables;
-
-namespace trainav.web.Pages;
-
-public class RegisterModel : PageModel {
- public void OnPost() {
- if (!Request.HasFormContentType
- || string.IsNullOrWhiteSpace(Request.Form["user"])
- || string.IsNullOrWhiteSpace(Request.Form["pass"])
- || string.IsNullOrWhiteSpace(Request.Form["code"]))
- return;
-
- if (Request.Form["code"] != System.IO.File.ReadAllLines("regkey.txt")[0])
- return;
-
- using var db = new Database.DbConn();
- var user = db.Users.FirstOrDefault(p => p.Username == Request.Form["user"].ToString());
- if (user != null)
- return; //user already exists
-
- var uid = db.InsertWithInt32Identity(new User { Username = Request.Form["user"].ToString(), Password = Request.Form["pass"].ToString().Sha256() });
-
- HttpContext.Session.SetString("uid", uid.ToString());
- HttpContext.Session.SetString("authorized", "true");
- }
-}
diff --git a/trainav.web/Pages/Shared/_Layout.cshtml b/trainav.web/Pages/Shared/_Layout.cshtml
index 1476992..4614785 100644
--- a/trainav.web/Pages/Shared/_Layout.cshtml
+++ b/trainav.web/Pages/Shared/_Layout.cshtml
@@ -1,67 +1,41 @@
-@using Microsoft.AspNetCore.Http
-
+
-
-
- @ViewData["Title"] - Trainav
-
-
+
+
+ @ViewData["Title"] - Trainav
+
+
-
-
-
Trainav v2
-
-
-
-
-
-
- Home
-
- @if (Context.Session.GetString("authorized") == "true") {
-
- Plain
-
-
- Cards
-
- }
-
-
- @if (Context.Session.GetString("authorized") != "true") {
-
- Login
-
-
- Register
-
- }
-
- else {
-
- Logout
-
- }
-
-
-
-
-
+
+
+
-
- @RenderBody()
-
+
+ @RenderBody()
+
@@ -70,4 +44,4 @@
@RenderSection("Scripts", false)
-
+