From 5eacd5a7ec8bdb1fec1fc9007734baed6b35c781 Mon Sep 17 00:00:00 2001
From: Laura Hausmann
Date: Fri, 12 Jun 2020 00:37:55 +0200
Subject: [PATCH] display card/qr expiry & refresh; refactor Cards page; code
cleanup
---
bahnplan.web/Controllers/TestController.cs | 22 +-
.../JSON/CardResponse/CardResponse.cs | 302 ++++++++------
.../ListOrdersResponse/ListOrdersResponse.cs | 100 +++--
bahnplan.web/JSON/OEAPIResponse.cs | 371 +++++++++++-------
bahnplan.web/JSON/TicketResponse.cs | 13 +-
bahnplan.web/Pages/Card.cshtml | 2 +-
bahnplan.web/Pages/Card.cshtml.cs | 9 +-
bahnplan.web/Pages/Cards.cshtml | 163 ++++++--
bahnplan.web/Pages/Cards.cshtml.cs | 37 +-
bahnplan.web/Pages/Delete.cshtml | 29 +-
bahnplan.web/Pages/Delete.cshtml.cs | 7 +-
bahnplan.web/Pages/Error.cshtml.cs | 14 +-
bahnplan.web/Pages/Index.cshtml | 1 -
bahnplan.web/Pages/Index.cshtml.cs | 7 +-
bahnplan.web/Pages/Inspection.cshtml | 56 ++-
bahnplan.web/Pages/Inspection.cshtml.cs | 11 +-
bahnplan.web/Pages/Login.cshtml.cs | 16 +-
bahnplan.web/Pages/Logout.cshtml | 2 +-
bahnplan.web/Pages/Logout.cshtml.cs | 7 -
bahnplan.web/Pages/OEAPI.cshtml | 4 +-
bahnplan.web/Pages/OEAPI.cshtml.cs | 17 +-
bahnplan.web/Pages/Privacy.cshtml.cs | 11 +-
bahnplan.web/Pages/Register.cshtml.cs | 16 +-
bahnplan.web/Pages/Shared/_Layout.cshtml | 2 +-
bahnplan.web/Pages/Ticket.cshtml | 4 +-
bahnplan.web/Pages/Ticket.cshtml.cs | 25 +-
bahnplan.web/Pages/Trip.cshtml | 8 +-
bahnplan.web/Pages/Trip.cshtml.cs | 5 +-
bahnplan.web/Program.cs | 11 +-
bahnplan.web/Startup.cs | 9 +-
bahnplan.web/Variables.cs | 1 -
bahnplan.web/database/Database.cs | 13 +-
bahnplan.web/database/Tables/Card.cs | 64 ++-
bahnplan.web/database/Tables/Leg.cs | 37 +-
bahnplan.web/database/Tables/Ticket.cs | 25 +-
bahnplan.web/database/Tables/TicketLeg.cs | 29 +-
bahnplan.web/database/Tables/Trip.cs | 3 +-
bahnplan.web/database/Tables/User.cs | 9 +-
.../lib/bootstrap/dist/js/bootstrap.bundle.js | 2 +-
.../lib/bootstrap/dist/js/bootstrap.js | 2 +-
.../jquery-validation/dist/jquery.validate.js | 2 +-
.../wwwroot/lib/jquery/dist/jquery.js | 2 +-
42 files changed, 859 insertions(+), 611 deletions(-)
diff --git a/bahnplan.web/Controllers/TestController.cs b/bahnplan.web/Controllers/TestController.cs
index 940618d..fc7d27f 100644
--- a/bahnplan.web/Controllers/TestController.cs
+++ b/bahnplan.web/Controllers/TestController.cs
@@ -1,29 +1,21 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Threading.Tasks;
+using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Logging;
namespace bahnplan.web.Controllers {
- [ApiController]
- [Route("api/[controller]")]
+ [ApiController, Route("api/[controller]")]
public class TestController : ControllerBase {
[HttpGet]
- public ApiResponse Get() {
- return new ApiResponse("test", 4);
- }
+ public ApiResponse Get() => new ApiResponse("test", 4);
}
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")]
public class ApiResponse {
- public string String1 { get; }
- public int Int1 { get; }
-
public ApiResponse(string string1, int int1) {
String1 = string1;
- Int1 = int1;
+ Int1 = int1;
}
+
+ public string String1 { get; }
+ public int Int1 { get; }
}
}
\ No newline at end of file
diff --git a/bahnplan.web/JSON/CardResponse/CardResponse.cs b/bahnplan.web/JSON/CardResponse/CardResponse.cs
index 5cd31d8..f643940 100644
--- a/bahnplan.web/JSON/CardResponse/CardResponse.cs
+++ b/bahnplan.web/JSON/CardResponse/CardResponse.cs
@@ -11,136 +11,204 @@ using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
-namespace bahnplan.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; }
- }
+namespace bahnplan.web.JSON.CardResponse {
+ public partial class CardResponse {
+ [JsonProperty("?xml", NullValueHandling = NullValueHandling.Ignore)]
+ public Xml Xml { 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; }
- }
+ [JsonProperty("rporderdetails", NullValueHandling = NullValueHandling.Ignore)]
+ public Rporderdetails Rporderdetails { 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 Rporderdetails {
+ [JsonProperty("@version", NullValueHandling = NullValueHandling.Ignore)]
+ public string Version { get; set; }
- public class Posinfolist
- {
- [JsonProperty("posinfo", NullValueHandling = NullValueHandling.Ignore)] public Posinfo Posinfo { get; set; }
- }
+ [JsonProperty("rpheader", NullValueHandling = NullValueHandling.Ignore)]
+ public Rpheader Rpheader { 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; }
- }
+ [JsonProperty("order", NullValueHandling = NullValueHandling.Ignore)]
+ public Order Order { get; set; }
+ }
- public class Tcklist
- {
- [JsonProperty("tck", NullValueHandling = NullValueHandling.Ignore)] public Tck Tck { get; set; }
- }
+ public class Order {
+ [JsonProperty("@cdt", NullValueHandling = NullValueHandling.Ignore)]
+ public string Cdt { 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; }
- }
+ [JsonProperty("@cid", NullValueHandling = NullValueHandling.Ignore)]
+ public string Cid { get; set; }
- public class Bahncardimage
- {
- [JsonProperty("#cdata-section", NullValueHandling = NullValueHandling.Ignore)] public string CdataSection { get; set; }
- }
+ [JsonProperty("@ddt", NullValueHandling = NullValueHandling.Ignore)]
+ public string Ddt { get; set; }
- public class Htdata
- {
- [JsonProperty("ht", NullValueHandling = NullValueHandling.Ignore)] public List Ht { get; set; }
- }
+ [JsonProperty("@fkat", NullValueHandling = NullValueHandling.Ignore)]
+ public string Fkat { 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; }
- }
+ [JsonProperty("@ldt", NullValueHandling = NullValueHandling.Ignore)]
+ public string Ldt { 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; }
- }
+ [JsonProperty("@on", NullValueHandling = NullValueHandling.Ignore)]
+ public string On { get; set; }
- public class Nvplist
- {
- [JsonProperty("nvp", NullValueHandling = NullValueHandling.Ignore)] public List Nvp { get; set; }
- }
+ [JsonProperty("@pg", NullValueHandling = NullValueHandling.Ignore)]
+ public string Pg { 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; }
- }
+ [JsonProperty("@sdt", NullValueHandling = NullValueHandling.Ignore)]
+ public string Sdt { 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; }
- }
+ [JsonProperty("@version", NullValueHandling = NullValueHandling.Ignore)]
+ public string Version { 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; }
- }
+ [JsonProperty("@vfrom", NullValueHandling = NullValueHandling.Ignore)]
+ public string Vfrom { get; set; }
- public partial class CardResponse
- {
- public static CardResponse FromJson(string json) => JsonConvert.DeserializeObject(json, Converter.Settings);
- }
+ [JsonProperty("@vto", NullValueHandling = NullValueHandling.Ignore)]
+ public string Vto { get; set; }
- internal static class Converter
- {
- public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
- {
- MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
- DateParseHandling = DateParseHandling.None,
- Converters =
- {
- new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
- },
- };
- }
-}
+ [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}}
+ };
+ }
+}
\ No newline at end of file
diff --git a/bahnplan.web/JSON/ListOrdersResponse/ListOrdersResponse.cs b/bahnplan.web/JSON/ListOrdersResponse/ListOrdersResponse.cs
index ee64773..6d829e7 100644
--- a/bahnplan.web/JSON/ListOrdersResponse/ListOrdersResponse.cs
+++ b/bahnplan.web/JSON/ListOrdersResponse/ListOrdersResponse.cs
@@ -9,53 +9,67 @@
using System.Collections.Generic;
using Newtonsoft.Json;
-namespace bahnplan.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; }
- }
+namespace bahnplan.web.JSON.ListOrdersResponse {
+ public partial class ListOrdersResponse {
+ [JsonProperty("?xml", NullValueHandling = NullValueHandling.Ignore)]
+ public Xml Xml { 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; }
- }
+ [JsonProperty("rporderheadlist", NullValueHandling = NullValueHandling.Ignore)]
+ public Rporderheadlist Rporderheadlist { get; set; }
+ }
- public class Orderheadlist
- {
- [JsonProperty("orderhead", NullValueHandling = NullValueHandling.Ignore)] public List Orderhead { get; set; }
- }
+ public class Rporderheadlist {
+ [JsonProperty("@version", NullValueHandling = NullValueHandling.Ignore)]
+ public string Version { 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; }
- }
+ [JsonProperty("rpheader", NullValueHandling = NullValueHandling.Ignore)]
+ public Rpheader Rpheader { 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; }
- }
+ [JsonProperty("orderheadlist", NullValueHandling = NullValueHandling.Ignore)]
+ public Orderheadlist Orderheadlist { 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 Orderheadlist {
+ [JsonProperty("orderhead", NullValueHandling = NullValueHandling.Ignore)]
+ public List Orderhead { 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 class Orderhead {
+ [JsonProperty("@ldt", NullValueHandling = NullValueHandling.Ignore)]
+ public string Ldt { get; set; }
- public partial class ListOrdersResponse
- {
- public static ListOrdersResponse FromJson(string json) => JsonConvert.DeserializeObject(json, Converter.Settings);
- }
-}
+ [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/bahnplan.web/JSON/OEAPIResponse.cs b/bahnplan.web/JSON/OEAPIResponse.cs
index 14cf3b4..d74f8eb 100644
--- a/bahnplan.web/JSON/OEAPIResponse.cs
+++ b/bahnplan.web/JSON/OEAPIResponse.cs
@@ -9,151 +9,254 @@
using System.Collections.Generic;
using Newtonsoft.Json;
-namespace bahnplan.web.JSON
-{
- using J = JsonPropertyAttribute;
- using R = Required;
- using N = NullValueHandling;
+namespace bahnplan.web.JSON {
+ using J = JsonPropertyAttribute;
+ using R = Required;
+ using N = NullValueHandling;
- public partial class OeapiResponse
- {
- [J("status", NullValueHandling = N.Ignore)] public string Status { get; set; }
- [J("msg", NullValueHandling = N.Ignore)] public string Msg { get; set; }
- [J("data", NullValueHandling = N.Ignore)] public Data Data { get; set; }
- }
+ public partial class OeapiResponse {
+ [J("status", NullValueHandling = N.Ignore)]
+ public string Status { get; set; }
- public class Data
- {
- [J("reqId", NullValueHandling = N.Ignore)] public string ReqId { get; set; }
- [J("lastUpdated", NullValueHandling = N.Ignore)] public long? LastUpdated { get; set; }
- [J("params", NullValueHandling = N.Ignore)] public Params Params { get; set; }
- [J("journeys", NullValueHandling = N.Ignore)] public Dictionary Journeys { get; set; }
- }
+ [J("msg", NullValueHandling = N.Ignore)]
+ public string Msg { get; set; }
- public class OJourney
- {
- [J("lastUpdated", NullValueHandling = N.Ignore)] public long? LastUpdated { get; set; }
- [J("legs", NullValueHandling = N.Ignore)] public List Legs { get; set; }
- [J("price")] public object Price { get; set; }
- }
+ [J("data", NullValueHandling = N.Ignore)]
+ public Data Data { get; set; }
+ }
- public class Leg
- {
- [J("isWalking", NullValueHandling = N.Ignore)] public bool? IsWalking { get; set; }
- [J("isTransfer", NullValueHandling = N.Ignore)] public bool? IsTransfer { get; set; }
- [J("cancelled", NullValueHandling = N.Ignore)] public bool? Cancelled { get; set; }
- [J("departure", NullValueHandling = N.Ignore)] public Arrival Departure { get; set; }
- [J("arrival", NullValueHandling = N.Ignore)] public Arrival Arrival { get; set; }
- [J("polyline")] public object Polyline { get; set; }
- [J("distance")] public object Distance { get; set; }
- [J("line", NullValueHandling = N.Ignore)] public Line Line { get; set; }
- [J("direction", NullValueHandling = N.Ignore)] public string Direction { get; set; }
- [J("stopovers", NullValueHandling = N.Ignore)] public List Stopovers { get; set; }
- [J("remarks", NullValueHandling = N.Ignore)] public List Remarks { get; set; }
- }
+ public class Data {
+ [J("reqId", NullValueHandling = N.Ignore)]
+ public string ReqId { get; set; }
- public class Arrival
- {
- [J("point", NullValueHandling = N.Ignore)] public Point Point { get; set; }
- [J("plannedTime")] public long? PlannedTime { get; set; }
- [J("prognosedTime")] public long? PrognosedTime { get; set; }
- [J("plannedPlatform")] public string PlannedPlatform { get; set; }
- [J("prognosedPlatform")] public object PrognosedPlatform { get; set; }
- }
+ [J("lastUpdated", NullValueHandling = N.Ignore)]
+ public long? LastUpdated { get; set; }
- public class Point
- {
- [J("stop", NullValueHandling = N.Ignore)] public Stop Stop { get; set; }
- [J("location")] public object Location { get; set; }
- }
+ [J("params", NullValueHandling = N.Ignore)]
+ public Params Params { get; set; }
- public class Stop
- {
- [J("id", NullValueHandling = N.Ignore)] public string Id { get; set; }
- [J("name", NullValueHandling = N.Ignore)] public string Name { get; set; }
- [J("location", NullValueHandling = N.Ignore)] public Location Location { get; set; }
- [J("products", NullValueHandling = N.Ignore)] public Products Products { get; set; }
- [J("station")] public object Station { get; set; }
- }
+ [J("journeys", NullValueHandling = N.Ignore)]
+ public Dictionary Journeys { get; set; }
+ }
- public class Location
- {
- [J("latitude", NullValueHandling = N.Ignore)] public double? Latitude { get; set; }
- [J("longitude", NullValueHandling = N.Ignore)] public double? Longitude { get; set; }
- [J("name")] public object Name { get; set; }
- [J("address")] public object Address { get; set; }
- [J("id")] public object Id { get; set; }
- }
+ public class OJourney {
+ [J("lastUpdated", NullValueHandling = N.Ignore)]
+ public long? LastUpdated { get; set; }
- public class Products
- {
- [J("nationalExp", NullValueHandling = N.Ignore)] public bool? NationalExp { get; set; }
- [J("national", NullValueHandling = N.Ignore)] public bool? National { get; set; }
- [J("regionalExp", NullValueHandling = N.Ignore)] public bool? RegionalExp { get; set; }
- [J("regional", NullValueHandling = N.Ignore)] public bool? Regional { get; set; }
- [J("suburban", NullValueHandling = N.Ignore)] public bool? Suburban { get; set; }
- [J("bus", NullValueHandling = N.Ignore)] public bool? Bus { get; set; }
- [J("ferry", NullValueHandling = N.Ignore)] public bool? Ferry { get; set; }
- [J("subway", NullValueHandling = N.Ignore)] public bool? Subway { get; set; }
- [J("tram", NullValueHandling = N.Ignore)] public bool? Tram { get; set; }
- [J("taxi", NullValueHandling = N.Ignore)] public bool? Taxi { get; set; }
- }
+ [J("legs", NullValueHandling = N.Ignore)]
+ public List Legs { get; set; }
- public class Line
- {
- [J("id", NullValueHandling = N.Ignore)] public string Id { get; set; }
- [J("name", NullValueHandling = N.Ignore)] public string Name { get; set; }
- [J("mode", NullValueHandling = N.Ignore)] public string Mode { get; set; }
- [J("product", NullValueHandling = N.Ignore)] public string Product { get; set; }
- [J("tripNum", NullValueHandling = N.Ignore)] public string TripNum { get; set; }
- [J("productName", NullValueHandling = N.Ignore)] public string ProductName { get; set; }
- [J("fullProductName", NullValueHandling = N.Ignore)] public string FullProductName { get; set; }
- [J("operator")] public object Operator { get; set; }
- [J("additionalName")] public string AdditionalName { get; set; }
- }
+ [J("price")] public object Price { get; set; }
+ }
- public class Remark
- {
- [J("type", NullValueHandling = N.Ignore)] public string Type { get; set; }
- [J("code", NullValueHandling = N.Ignore)] public string Code { get; set; }
- [J("summary")] public string Summary { get; set; }
- [J("text", NullValueHandling = N.Ignore)] public string Text { get; set; }
- [J("tripId")] public object TripId { get; set; }
- }
+ public class Leg {
+ [J("isWalking", NullValueHandling = N.Ignore)]
+ public bool? IsWalking { get; set; }
- public class Stopover
- {
- [J("stop", NullValueHandling = N.Ignore)] public Stop Stop { get; set; }
- [J("cancelled", NullValueHandling = N.Ignore)] public bool? Cancelled { get; set; }
- [J("departure", NullValueHandling = N.Ignore)] public Arrival Departure { get; set; }
- [J("arrival", NullValueHandling = N.Ignore)] public Arrival Arrival { get; set; }
- }
+ [J("isTransfer", NullValueHandling = N.Ignore)]
+ public bool? IsTransfer { get; set; }
- public class Params
- {
- [J("fromPoint", NullValueHandling = N.Ignore)] public Point FromPoint { get; set; }
- [J("toPoint", NullValueHandling = N.Ignore)] public Point ToPoint { get; set; }
- [J("viaPoint")] public object ViaPoint { get; set; }
- [J("earlierRef")] public object EarlierRef { get; set; }
- [J("laterRef")] public object LaterRef { get; set; }
- [J("results")] public object Results { get; set; }
- [J("stopovers", NullValueHandling = N.Ignore)] public bool? Stopovers { get; set; }
- [J("polylines", NullValueHandling = N.Ignore)] public bool? Polylines { get; set; }
- [J("remarks", NullValueHandling = N.Ignore)] public bool? Remarks { get; set; }
- [J("bikeFriendly")] public object BikeFriendly { get; set; }
- [J("tickets", NullValueHandling = N.Ignore)] public bool? Tickets { get; set; }
- [J("startWithWalking")] public object StartWithWalking { get; set; }
- [J("scheduledDays")] public object ScheduledDays { get; set; }
- [J("accessibility", NullValueHandling = N.Ignore)] public string Accessibility { get; set; }
- [J("transfers")] public object Transfers { get; set; }
- [J("transferTime")] public object TransferTime { get; set; }
- [J("arrival")] public object Arrival { get; set; }
- [J("departure", NullValueHandling = N.Ignore)] public long? Departure { get; set; }
- [J("products", NullValueHandling = N.Ignore)] public Products Products { get; set; }
- }
+ [J("cancelled", NullValueHandling = N.Ignore)]
+ public bool? Cancelled { get; set; }
- public partial class OeapiResponse
- {
- public static OeapiResponse FromJson(string json) => JsonConvert.DeserializeObject(json, Converter.Settings);
- }
-}
+ [J("departure", NullValueHandling = N.Ignore)]
+ public Arrival Departure { get; set; }
+
+ [J("arrival", NullValueHandling = N.Ignore)]
+ public Arrival Arrival { get; set; }
+
+ [J("polyline")] public object Polyline { get; set; }
+ [J("distance")] public object Distance { get; set; }
+
+ [J("line", NullValueHandling = N.Ignore)]
+ public Line Line { get; set; }
+
+ [J("direction", NullValueHandling = N.Ignore)]
+ public string Direction { get; set; }
+
+ [J("stopovers", NullValueHandling = N.Ignore)]
+ public List Stopovers { get; set; }
+
+ [J("remarks", NullValueHandling = N.Ignore)]
+ public List Remarks { get; set; }
+ }
+
+ public class Arrival {
+ [J("point", NullValueHandling = N.Ignore)]
+ public Point Point { get; set; }
+
+ [J("plannedTime")] public long? PlannedTime { get; set; }
+ [J("prognosedTime")] public long? PrognosedTime { get; set; }
+ [J("plannedPlatform")] public string PlannedPlatform { get; set; }
+ [J("prognosedPlatform")] public object PrognosedPlatform { get; set; }
+ }
+
+ public class Point {
+ [J("stop", NullValueHandling = N.Ignore)]
+ public Stop Stop { get; set; }
+
+ [J("location")] public object Location { get; set; }
+ }
+
+ public class Stop {
+ [J("id", NullValueHandling = N.Ignore)]
+ public string Id { get; set; }
+
+ [J("name", NullValueHandling = N.Ignore)]
+ public string Name { get; set; }
+
+ [J("location", NullValueHandling = N.Ignore)]
+ public Location Location { get; set; }
+
+ [J("products", NullValueHandling = N.Ignore)]
+ public Products Products { get; set; }
+
+ [J("station")] public object Station { get; set; }
+ }
+
+ public class Location {
+ [J("latitude", NullValueHandling = N.Ignore)]
+ public double? Latitude { get; set; }
+
+ [J("longitude", NullValueHandling = N.Ignore)]
+ public double? Longitude { get; set; }
+
+ [J("name")] public object Name { get; set; }
+ [J("address")] public object Address { get; set; }
+ [J("id")] public object Id { get; set; }
+ }
+
+ public class Products {
+ [J("nationalExp", NullValueHandling = N.Ignore)]
+ public bool? NationalExp { get; set; }
+
+ [J("national", NullValueHandling = N.Ignore)]
+ public bool? National { get; set; }
+
+ [J("regionalExp", NullValueHandling = N.Ignore)]
+ public bool? RegionalExp { get; set; }
+
+ [J("regional", NullValueHandling = N.Ignore)]
+ public bool? Regional { get; set; }
+
+ [J("suburban", NullValueHandling = N.Ignore)]
+ public bool? Suburban { get; set; }
+
+ [J("bus", NullValueHandling = N.Ignore)]
+ public bool? Bus { get; set; }
+
+ [J("ferry", NullValueHandling = N.Ignore)]
+ public bool? Ferry { get; set; }
+
+ [J("subway", NullValueHandling = N.Ignore)]
+ public bool? Subway { get; set; }
+
+ [J("tram", NullValueHandling = N.Ignore)]
+ public bool? Tram { get; set; }
+
+ [J("taxi", NullValueHandling = N.Ignore)]
+ public bool? Taxi { get; set; }
+ }
+
+ public class Line {
+ [J("id", NullValueHandling = N.Ignore)]
+ public string Id { get; set; }
+
+ [J("name", NullValueHandling = N.Ignore)]
+ public string Name { get; set; }
+
+ [J("mode", NullValueHandling = N.Ignore)]
+ public string Mode { get; set; }
+
+ [J("product", NullValueHandling = N.Ignore)]
+ public string Product { get; set; }
+
+ [J("tripNum", NullValueHandling = N.Ignore)]
+ public string TripNum { get; set; }
+
+ [J("productName", NullValueHandling = N.Ignore)]
+ public string ProductName { get; set; }
+
+ [J("fullProductName", NullValueHandling = N.Ignore)]
+ public string FullProductName { get; set; }
+
+ [J("operator")] public object Operator { get; set; }
+ [J("additionalName")] public string AdditionalName { get; set; }
+ }
+
+ public class Remark {
+ [J("type", NullValueHandling = N.Ignore)]
+ public string Type { get; set; }
+
+ [J("code", NullValueHandling = N.Ignore)]
+ public string Code { get; set; }
+
+ [J("summary")] public string Summary { get; set; }
+
+ [J("text", NullValueHandling = N.Ignore)]
+ public string Text { get; set; }
+
+ [J("tripId")] public object TripId { get; set; }
+ }
+
+ public class Stopover {
+ [J("stop", NullValueHandling = N.Ignore)]
+ public Stop Stop { get; set; }
+
+ [J("cancelled", NullValueHandling = N.Ignore)]
+ public bool? Cancelled { get; set; }
+
+ [J("departure", NullValueHandling = N.Ignore)]
+ public Arrival Departure { get; set; }
+
+ [J("arrival", NullValueHandling = N.Ignore)]
+ public Arrival Arrival { get; set; }
+ }
+
+ public class Params {
+ [J("fromPoint", NullValueHandling = N.Ignore)]
+ public Point FromPoint { get; set; }
+
+ [J("toPoint", NullValueHandling = N.Ignore)]
+ public Point ToPoint { get; set; }
+
+ [J("viaPoint")] public object ViaPoint { get; set; }
+ [J("earlierRef")] public object EarlierRef { get; set; }
+ [J("laterRef")] public object LaterRef { get; set; }
+ [J("results")] public object Results { get; set; }
+
+ [J("stopovers", NullValueHandling = N.Ignore)]
+ public bool? Stopovers { get; set; }
+
+ [J("polylines", NullValueHandling = N.Ignore)]
+ public bool? Polylines { get; set; }
+
+ [J("remarks", NullValueHandling = N.Ignore)]
+ public bool? Remarks { get; set; }
+
+ [J("bikeFriendly")] public object BikeFriendly { get; set; }
+
+ [J("tickets", NullValueHandling = N.Ignore)]
+ public bool? Tickets { get; set; }
+
+ [J("startWithWalking")] public object StartWithWalking { get; set; }
+ [J("scheduledDays")] public object ScheduledDays { get; set; }
+
+ [J("accessibility", NullValueHandling = N.Ignore)]
+ public string Accessibility { get; set; }
+
+ [J("transfers")] public object Transfers { get; set; }
+ [J("transferTime")] public object TransferTime { get; set; }
+ [J("arrival")] public object Arrival { get; set; }
+
+ [J("departure", NullValueHandling = N.Ignore)]
+ public long? Departure { get; set; }
+
+ [J("products", NullValueHandling = N.Ignore)]
+ public Products Products { get; set; }
+ }
+
+ public partial class OeapiResponse {
+ public static OeapiResponse FromJson(string json) => JsonConvert.DeserializeObject(json, Converter.Settings);
+ }
+}
\ No newline at end of file
diff --git a/bahnplan.web/JSON/TicketResponse.cs b/bahnplan.web/JSON/TicketResponse.cs
index 7e00bce..685020d 100644
--- a/bahnplan.web/JSON/TicketResponse.cs
+++ b/bahnplan.web/JSON/TicketResponse.cs
@@ -246,8 +246,7 @@ namespace bahnplan.web.JSON {
}
public class Trainlist {
- [J("train", NullValueHandling = NV.Ignore)]
- [JsonConverter(typeof(SingleOrArrayConverter))]
+ [J("train", NullValueHandling = NV.Ignore), JsonConverter(typeof(SingleOrArrayConverter))]
public List Train { get; set; }
}
@@ -411,22 +410,20 @@ namespace bahnplan.web.JSON {
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings {
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
- Converters = {new IsoDateTimeConverter {DateTimeStyles = DateTimeStyles.AssumeUniversal}},
+ Converters = {new IsoDateTimeConverter {DateTimeStyles = DateTimeStyles.AssumeUniversal}}
};
}
internal class SingleOrArrayConverter : JsonConverter {
- public override bool CanConvert(Type objectType) {
- return objectType == typeof(List);
- }
+ 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 bool CanWrite => false;
-
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
throw new NotImplementedException();
}
diff --git a/bahnplan.web/Pages/Card.cshtml b/bahnplan.web/Pages/Card.cshtml
index 892fd81..7d08995 100644
--- a/bahnplan.web/Pages/Card.cshtml
+++ b/bahnplan.web/Pages/Card.cshtml
@@ -5,7 +5,7 @@
@{
ViewData["Title"] = "Card";
Response.Redirect("/Cards");
-
+
if (HttpContext.Session.GetString("authorized") != "true") {
Response.Redirect("/");
return;
diff --git a/bahnplan.web/Pages/Card.cshtml.cs b/bahnplan.web/Pages/Card.cshtml.cs
index bb5b103..76c9af8 100644
--- a/bahnplan.web/Pages/Card.cshtml.cs
+++ b/bahnplan.web/Pages/Card.cshtml.cs
@@ -4,22 +4,19 @@ using System.Xml;
using System.Xml.Linq;
using bahnplan.web.database;
using bahnplan.web.database.Tables;
-using bahnplan.web.JSON;
using bahnplan.web.JSON.CardResponse;
using bahnplan.web.JSON.ListOrdersResponse;
using LinqToDB;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Newtonsoft.Json;
-using Leg = bahnplan.web.database.Tables.Leg;
namespace bahnplan.web.Pages {
public class CardModel : PageModel {
public void OnPost() {
- if (HttpContext.Session.GetString("authorized") != "true") {
+ 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"),
@@ -63,7 +60,7 @@ namespace bahnplan.web.Pages {
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,
+ QrValidTo = parsedCard.Rporderdetails.Order.Tcklist.Tck.Mtk.Nvplist.Nvp.First(p => p.Name == "ebcbarcodegueltigbis").Text
});
}
}
diff --git a/bahnplan.web/Pages/Cards.cshtml b/bahnplan.web/Pages/Cards.cshtml
index 8c6ab17..d3d1078 100644
--- a/bahnplan.web/Pages/Cards.cshtml
+++ b/bahnplan.web/Pages/Cards.cshtml
@@ -8,37 +8,140 @@
Response.Redirect("/");
return;
}
+
+ if (Request.Query.ContainsKey("refresh")) {
+ Response.Redirect("?edit=true");
+ return;
+ }
}
-@foreach (var card in Model.Cards) {
-
-
-
-
-
+@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
+ |
+
+ }
+
+
+ Back
+
+
}
-
- Click on the BahnCard Image to remove a card.
-
-
-
-
-
-
-
-Get Cards from bahn.de account
-
-
\ No newline at end of file
+else if (Model.Cards.Any()) {
+ foreach (var card in Model.Cards) {
+
+
+
+ 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
+
+
+}
\ No newline at end of file
diff --git a/bahnplan.web/Pages/Cards.cshtml.cs b/bahnplan.web/Pages/Cards.cshtml.cs
index 6677679..c1ac354 100644
--- a/bahnplan.web/Pages/Cards.cshtml.cs
+++ b/bahnplan.web/Pages/Cards.cshtml.cs
@@ -1,20 +1,51 @@
using System.Collections.Generic;
using System.Linq;
+using System.Net;
+using System.Xml;
+using System.Xml.Linq;
using bahnplan.web.database;
using bahnplan.web.database.Tables;
+using bahnplan.web.JSON.CardResponse;
+using LinqToDB;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.RazorPages;
+using Newtonsoft.Json;
namespace bahnplan.web.Pages {
public class CardsModel : PageModel {
public List Cards;
public void OnGet() {
- if (HttpContext.Session.GetString("authorized") != "true") {
+ 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"]));
+ 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;
}
-
- using var db = new Database.DbConn();
+
Cards = db.Cards.Where(p => p.UserId == int.Parse(HttpContext.Session.GetString("uid"))).ToList();
}
}
diff --git a/bahnplan.web/Pages/Delete.cshtml b/bahnplan.web/Pages/Delete.cshtml
index be6c22f..fa70cf2 100644
--- a/bahnplan.web/Pages/Delete.cshtml
+++ b/bahnplan.web/Pages/Delete.cshtml
@@ -1,7 +1,6 @@
@page
@using Microsoft.AspNetCore.Http
@using bahnplan.web.database
-@using System.Linq
@model DeleteModel
@{
ViewData["Title"] = "Home";
@@ -13,19 +12,19 @@
if (Request.Query.ContainsKey("confirm") && Request.Query["confirm"] == "true") {
Layout = null;
- Response.Redirect(Request.Headers["Referer"]);
+ Response.Redirect("/");
+ return;
}
- else {
- Are you sure?
-
- You are attempting to delete
- @{
- await using var db = new Database.DbConn();
- }
- @switch (Request.Query["item"]) {
+
Are you sure?
+
+ You are attempting to delete
+ @{
+ await using var db = new Database.DbConn();
+
+ switch (Request.Query["item"]) {
case "trip": {
- var legs = db.Legs.Where(p => p.TripId == int.Parse(Request.Query["id"])).OrderBy(p => p.DepTime).ToList();;
+ 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
@@ -48,8 +47,8 @@
break;
}
}
-
- Cancel
- Confirm
- }
+ }
+
+ Cancel
+ Confirm
}
\ No newline at end of file
diff --git a/bahnplan.web/Pages/Delete.cshtml.cs b/bahnplan.web/Pages/Delete.cshtml.cs
index d0c58dc..6a5aff5 100644
--- a/bahnplan.web/Pages/Delete.cshtml.cs
+++ b/bahnplan.web/Pages/Delete.cshtml.cs
@@ -1,14 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
+using System.Linq;
using bahnplan.web.database;
using bahnplan.web.database.Tables;
using LinqToDB;
using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
namespace bahnplan.web.Pages {
public class DeleteModel : PageModel {
diff --git a/bahnplan.web/Pages/Error.cshtml.cs b/bahnplan.web/Pages/Error.cshtml.cs
index 7cc24f3..b4703a4 100644
--- a/bahnplan.web/Pages/Error.cshtml.cs
+++ b/bahnplan.web/Pages/Error.cshtml.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
@@ -10,16 +6,14 @@ using Microsoft.Extensions.Logging;
namespace bahnplan.web.Pages {
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public class ErrorModel : PageModel {
+ private readonly ILogger _logger;
+
+ public ErrorModel(ILogger logger) => _logger = logger;
+
public string RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
- private readonly ILogger _logger;
-
- public ErrorModel(ILogger logger) {
- _logger = logger;
- }
-
public void OnGet() {
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
diff --git a/bahnplan.web/Pages/Index.cshtml b/bahnplan.web/Pages/Index.cshtml
index fc5ec18..1f93c41 100644
--- a/bahnplan.web/Pages/Index.cshtml
+++ b/bahnplan.web/Pages/Index.cshtml
@@ -1,7 +1,6 @@
@page
@using Microsoft.AspNetCore.Http
@using bahnplan.web.database
-@using System.Linq
@model IndexModel
@{
ViewData["Title"] = "Home";
diff --git a/bahnplan.web/Pages/Index.cshtml.cs b/bahnplan.web/Pages/Index.cshtml.cs
index 4c9b69a..dbbb4ea 100644
--- a/bahnplan.web/Pages/Index.cshtml.cs
+++ b/bahnplan.web/Pages/Index.cshtml.cs
@@ -1,13 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
+using System.Linq;
using bahnplan.web.database;
using bahnplan.web.database.Tables;
using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
namespace bahnplan.web.Pages {
public class IndexModel : PageModel {
diff --git a/bahnplan.web/Pages/Inspection.cshtml b/bahnplan.web/Pages/Inspection.cshtml
index aeb06de..734f803 100644
--- a/bahnplan.web/Pages/Inspection.cshtml
+++ b/bahnplan.web/Pages/Inspection.cshtml
@@ -1,10 +1,10 @@
@page
-@using bahnplan.web.database
@using Microsoft.AspNetCore.Http
+@using bahnplan.web.database
@model InspectionModel
@{
ViewData["Title"] = "Inspection";
-
+
if (HttpContext.Session.GetString("authorized") != "true") {
Response.Redirect("/");
return;
@@ -29,6 +29,32 @@
+
+ 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 {
@@ -43,6 +69,32 @@ else if (Model.Ticket.TicketInfo.Contains("BC 25")) {
+
+ 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 {
diff --git a/bahnplan.web/Pages/Inspection.cshtml.cs b/bahnplan.web/Pages/Inspection.cshtml.cs
index c83adfb..731a930 100644
--- a/bahnplan.web/Pages/Inspection.cshtml.cs
+++ b/bahnplan.web/Pages/Inspection.cshtml.cs
@@ -1,4 +1,3 @@
-using System.Collections.Generic;
using System.Linq;
using bahnplan.web.database;
using bahnplan.web.database.Tables;
@@ -7,16 +6,16 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
namespace bahnplan.web.Pages {
public class InspectionModel : PageModel {
+ public Leg Leg;
public Ticket Ticket;
- public Leg Leg;
+
public void OnGet() {
- if (HttpContext.Session.GetString("authorized") != "true") {
+ if (HttpContext.Session.GetString("authorized") != "true")
return;
- }
-
+
using var db = new Database.DbConn();
Ticket = db.Tickets.First(p => p.TicketId == int.Parse(Request.Query["id"]));
- Leg = db.Legs.First(p => p.LegId == int.Parse(Request.Query["leg"]));
+ Leg = db.Legs.First(p => p.LegId == int.Parse(Request.Query["leg"]));
}
}
}
\ No newline at end of file
diff --git a/bahnplan.web/Pages/Login.cshtml.cs b/bahnplan.web/Pages/Login.cshtml.cs
index beaf19f..ad44b67 100644
--- a/bahnplan.web/Pages/Login.cshtml.cs
+++ b/bahnplan.web/Pages/Login.cshtml.cs
@@ -1,3 +1,4 @@
+using System;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
@@ -12,8 +13,7 @@ namespace bahnplan.web.Pages {
return;
using var db = new Database.DbConn();
- var user = db.Users.FirstOrDefault(p => p.Username == Request.Form["user"].ToString()
- && p.Password == Request.Form["pass"].ToString().Sha256());
+ var user = db.Users.FirstOrDefault(p => p.Username == Request.Form["user"].ToString() && p.Password == Request.Form["pass"].ToString().Sha256());
if (user == null)
return;
@@ -24,28 +24,26 @@ namespace bahnplan.web.Pages {
//TODO
}
}
-
+
public static class StringExtensions {
public static string Sha256(this string rawData) {
// Create a SHA256
using var sha256Hash = SHA256.Create();
-
+
// ComputeHash - returns byte array
var bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(rawData));
// Convert byte array to a string
var builder = new StringBuilder();
- for (var i = 0; i < bytes.Length; i++) {
+ for (var i = 0; i < bytes.Length; i++)
builder.Append(bytes[i].ToString("x2"));
- }
return builder.ToString();
}
-
+
public static string Base64Encode(this string plainText) {
var plainTextBytes = Encoding.UTF8.GetBytes(plainText);
- return System.Convert.ToBase64String(plainTextBytes);
+ return Convert.ToBase64String(plainTextBytes);
}
-
}
}
\ No newline at end of file
diff --git a/bahnplan.web/Pages/Logout.cshtml b/bahnplan.web/Pages/Logout.cshtml
index 0000e03..e3147e1 100644
--- a/bahnplan.web/Pages/Logout.cshtml
+++ b/bahnplan.web/Pages/Logout.cshtml
@@ -4,4 +4,4 @@
@{
Layout = null;
Response.Redirect("/");
-}
+}
\ No newline at end of file
diff --git a/bahnplan.web/Pages/Logout.cshtml.cs b/bahnplan.web/Pages/Logout.cshtml.cs
index c734b00..bb83235 100644
--- a/bahnplan.web/Pages/Logout.cshtml.cs
+++ b/bahnplan.web/Pages/Logout.cshtml.cs
@@ -1,10 +1,3 @@
-using System.Linq;
-using System.Security.Cryptography;
-using System.Text;
-using bahnplan.web.database;
-using bahnplan.web.database.Tables;
-using LinqToDB;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace bahnplan.web.Pages {
diff --git a/bahnplan.web/Pages/OEAPI.cshtml b/bahnplan.web/Pages/OEAPI.cshtml
index 9c0e4ca..bef8576 100644
--- a/bahnplan.web/Pages/OEAPI.cshtml
+++ b/bahnplan.web/Pages/OEAPI.cshtml
@@ -3,12 +3,12 @@
@model OEAPIModel
@{
ViewData["Title"] = "OEAPI";
-
+
if (HttpContext.Session.GetString("authorized") != "true") {
Response.Redirect("/");
return;
}
-
+
Response.Redirect("/Trip?id=" + Model.TripId + "&edit=true");
}
diff --git a/bahnplan.web/Pages/OEAPI.cshtml.cs b/bahnplan.web/Pages/OEAPI.cshtml.cs
index 3ff0ef3..43097c6 100644
--- a/bahnplan.web/Pages/OEAPI.cshtml.cs
+++ b/bahnplan.web/Pages/OEAPI.cshtml.cs
@@ -1,21 +1,12 @@
using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
using System.Linq;
using System.Net;
-using System.Threading.Tasks;
-using System.Xml;
-using System.Xml.Linq;
using bahnplan.web.database;
using bahnplan.web.database.Tables;
using bahnplan.web.JSON;
using LinqToDB;
using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-using Newtonsoft.Json;
using Leg = bahnplan.web.database.Tables.Leg;
// ReSharper disable PossibleInvalidOperationException
@@ -25,11 +16,9 @@ namespace bahnplan.web.Pages {
public int TripId;
public void OnGet() {
-
- if (HttpContext.Session.GetString("authorized") != "true") {
+ if (HttpContext.Session.GetString("authorized") != "true")
return;
- }
-
+
var link = Request.Query["link"].ToString();
var shortcode = link;
if (link.Contains("oeffisear.ch"))
@@ -61,7 +50,7 @@ namespace bahnplan.web.Pages {
ArrTime = arrtime.ToString("yyyy-MM-ddTHH:mm:ss"),
DepStation = journey.Departure.Point.Stop.Name,
DepStationId = int.Parse(journey.Departure.Point.Stop.Id),
- DepTime = deptime.ToString("yyyy-MM-ddTHH:mm:ss"),
+ DepTime = deptime.ToString("yyyy-MM-ddTHH:mm:ss")
});
}
diff --git a/bahnplan.web/Pages/Privacy.cshtml.cs b/bahnplan.web/Pages/Privacy.cshtml.cs
index 9c703ae..0376f3f 100644
--- a/bahnplan.web/Pages/Privacy.cshtml.cs
+++ b/bahnplan.web/Pages/Privacy.cshtml.cs
@@ -1,18 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
+using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
namespace bahnplan.web.Pages {
public class PrivacyModel : PageModel {
private readonly ILogger
_logger;
- public PrivacyModel(ILogger logger) {
- _logger = logger;
- }
+ public PrivacyModel(ILogger logger) => _logger = logger;
public void OnGet() { }
}
diff --git a/bahnplan.web/Pages/Register.cshtml.cs b/bahnplan.web/Pages/Register.cshtml.cs
index 404929f..fc28753 100644
--- a/bahnplan.web/Pages/Register.cshtml.cs
+++ b/bahnplan.web/Pages/Register.cshtml.cs
@@ -1,6 +1,4 @@
using System.Linq;
-using System.Security.Cryptography;
-using System.Text;
using bahnplan.web.database;
using bahnplan.web.database.Tables;
using LinqToDB;
@@ -10,21 +8,21 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
namespace bahnplan.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"]))
+ 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());
+ 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(),
- });
+ 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/bahnplan.web/Pages/Shared/_Layout.cshtml b/bahnplan.web/Pages/Shared/_Layout.cshtml
index 576965c..33c7c7f 100644
--- a/bahnplan.web/Pages/Shared/_Layout.cshtml
+++ b/bahnplan.web/Pages/Shared/_Layout.cshtml
@@ -65,6 +65,6 @@
-@RenderSection("Scripts", required: false)
+@RenderSection("Scripts", false)