Public release

This commit is contained in:
Laura Hausmann 2020-06-11 20:29:16 +02:00
commit 4ef567d257
Signed by: zotan
GPG Key ID: 5EC1D38FFC321311
91 changed files with 41951 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

152
.gitignore vendored Normal file
View File

@ -0,0 +1,152 @@
/packages/
/_ReSharper.Caches/
# Created by https://www.toptal.com/developers/gitignore/api/rider,dotnetcore,jetbrains+all
# Edit at https://www.toptal.com/developers/gitignore?templates=rider,dotnetcore,jetbrains+all
### DotnetCore ###
# .NET Core build folders
bin/
obj/
# Common node modules locations
/node_modules
/wwwroot/node_modules
### JetBrains+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### JetBrains+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
.idea/
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
*.iml
modules.xml
.idea/misc.xml
*.ipr
# Sonarlint plugin
.idea/sonarlint
### Rider ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
# Generated files
# Sensitive or high-churn files
# Gradle
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
# Mongo Explorer plugin
# File-based project format
# IntelliJ
# mpeltonen/sbt-idea plugin
# JIRA plugin
# Cursive Clojure plugin
# Crashlytics plugin (for Android Studio and IntelliJ)
# Editor-based Rest Client
# Android studio 3.1+ serialized cache file
# End of https://www.toptal.com/developers/gitignore/api/rider,dotnetcore,jetbrains+all
database.db
regkey.txt

23
LICENSE Normal file
View File

@ -0,0 +1,23 @@
MIT License
Copyright (c) 2020 Laura Hausmann
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

10
README.md Normal file
View File

@ -0,0 +1,10 @@
# bahnplan.web or DBNav2
- Copy database.db.example to database.db
- Generate a random string (or use something else) and save it to regkey.txt to allow registrations
## DISCLAIMER
- This is very early alpha
- Stuff WILL break
- I am not responsible if some DB guy comes knocking on your doorstep if you use this or this software creates any kind of other damages
- Most importantly: have fun.

16
bahnplan.sln Normal file
View File

@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bahnplan.web", "bahnplan.web\bahnplan.web.csproj", "{41B83C7E-6F7E-4EE0-A332-D87A7FE3183E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{41B83C7E-6F7E-4EE0-A332-D87A7FE3183E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41B83C7E-6F7E-4EE0-A332-D87A7FE3183E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41B83C7E-6F7E-4EE0-A332-D87A7FE3183E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41B83C7E-6F7E-4EE0-A332-D87A7FE3183E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace bahnplan.web.Controllers {
[ApiController]
[Route("api/[controller]")]
public class TestController : ControllerBase {
[HttpGet]
public ApiResponse Get() {
return 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;
}
}
}

View File

@ -0,0 +1,146 @@
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using bahnplan.web.JSON.CardResponse;
//
// var cardResponse = CardResponse.FromJson(jsonString);
using System.Collections.Generic;
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; }
}
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> 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> 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<CardResponse>(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 }
},
};
}
}

View File

@ -0,0 +1,61 @@
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using bahnplan.web.JSON;
//
// var listOrdersResponse = ListOrdersResponse.FromJson(jsonString);
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; }
}
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> 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<ListOrdersResponse>(json, Converter.Settings);
}
}

View File

@ -0,0 +1,159 @@
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using bahnplan.web.JSON;
//
// var oeapiResponse = OeapiResponse.FromJson(jsonString);
using System.Collections.Generic;
using Newtonsoft.Json;
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 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<string, OJourney> Journeys { get; set; }
}
public class OJourney
{
[J("lastUpdated", NullValueHandling = N.Ignore)] public long? LastUpdated { get; set; }
[J("legs", NullValueHandling = N.Ignore)] public List<Leg> Legs { get; set; }
[J("price")] public object Price { 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<Stopover> Stopovers { get; set; }
[J("remarks", NullValueHandling = N.Ignore)] public List<Remark> 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<OeapiResponse>(json, Converter.Settings);
}
}

View File

@ -0,0 +1,434 @@
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using bahnplan.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 bahnplan.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)]
public PosinfoElement Posinfo { get; set; }
}
public class FluffyChildlist {
[J("posinfo", NullValueHandling = NV.Ignore)]
public List<PosinfoElement> 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)]
public PurplePosinfo 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)]
public List<Re> 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> 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)]
public Platz 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 Out Out { get; set; }
}
public class Out {
[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<Train>))]
public List<Train> 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)]
public Tck 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> 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<TicketResponse>(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<T> : JsonConverter {
public override bool CanConvert(Type objectType) {
return objectType == typeof(List<T>);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
var token = JToken.Load(reader);
return token.Type == JTokenType.Array ? token.ToObject<List<T>>() : new List<T> {token.ToObject<T>()};
}
public override bool CanWrite => false;
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,15 @@
@page
@using Microsoft.AspNetCore.Http
@model CardModel
@{
ViewData["Title"] = "Card";
Response.Redirect("/Cards");
if (HttpContext.Session.GetString("authorized") != "true") {
Response.Redirect("/");
return;
}
}
Card saved. Redirecting...

View File

@ -0,0 +1,71 @@
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;
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") {
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,
});
}
}
}
}

View File

@ -0,0 +1,44 @@
@page
@using Microsoft.AspNetCore.Http
@model CardsModel
@{
ViewData["Title"] = "Cards";
if (HttpContext.Session.GetString("authorized") != "true") {
Response.Redirect("/");
return;
}
}
@foreach (var card in Model.Cards) {
<img src="@card.CardQr" alt="Ticketcode"/>
<img src="@card.CardSecCode" alt="Sichtmerkmal"/>
<a href="/Delete?item=card&id=@card.CardId">
<img style="margin: -50px; height: 450px; transform: rotate(-90deg); position: relative; left: 130px" src='data:image/svg+xml;base64,@card.CardImage.Base64Encode()' alt="Bahncardimage"/>
</a>
<br/>
}
<p style="text-align: right">
Click on the BahnCard Image to remove a card.
</p>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<h3>Get Cards from bahn.de account</h3>
<br/>
<form method="POST" action="/Card">
<div class="form-group">
<input type="text" class="form-control" id="InputUser" name="user" placeholder="bahn.de username">
</div>
<div class="form-group">
<input type="password" class="form-control" id="InputPassword" name="pass" placeholder="bahn.de password">
</div>
<div class="form-group">
<input type="text" class="form-control" id="inputName" name="name" placeholder="Last name of traveller">
</div>
@Html.AntiForgeryToken()
<button type="submit" class="btn btn-primary">Submit</button>
</form>

View File

@ -0,0 +1,21 @@
using System.Collections.Generic;
using System.Linq;
using bahnplan.web.database;
using bahnplan.web.database.Tables;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace bahnplan.web.Pages {
public class CardsModel : PageModel {
public List<Card> Cards;
public void OnGet() {
if (HttpContext.Session.GetString("authorized") != "true") {
return;
}
using var db = new Database.DbConn();
Cards = db.Cards.Where(p => p.UserId == int.Parse(HttpContext.Session.GetString("uid"))).ToList();
}
}
}

View File

@ -0,0 +1,17 @@
@page
@using Microsoft.AspNetCore.Http
@using bahnplan.web.database
@using System.Linq
@model DeleteModel
@{
ViewData["Title"] = "Home";
if (HttpContext.Session.GetString("authorized") != "true") {
Response.Redirect("/");
return;
}
Layout = null;
Response.Redirect(Request.Headers["Referer"]);
}

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
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 {
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);
var id = int.Parse(Request.Query["id"]);
switch (Request.Query["item"]) {
case "trip": {
db.Trips.Delete(p => p.TripId == id);
db.Legs.Delete(p => p.TripId == id);
break;
}
case "leg": {
var tripid = db.Legs.First(p => p.LegId == id).TripId;
db.Legs.Delete(p => p.LegId == id);
if (!db.Legs.Any(p => p.TripId == tripid))
db.Trips.Delete(p => p.TripId == tripid);
break;
}
case "ticket": {
db.Legs.Where(p => p.LegId == id).Set(p => p.TicketId, 0).Update();
break;
}
case "card": {
db.Cards.Delete(p => p.CardId == id);
break;
}
}
}
}
}

View File

@ -0,0 +1,25 @@
@page
@model ErrorModel
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId) {
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>

View File

@ -0,0 +1,27 @@
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;
namespace bahnplan.web.Pages {
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public class ErrorModel : PageModel {
public string RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
private readonly ILogger<ErrorModel> _logger;
public ErrorModel(ILogger<ErrorModel> logger) {
_logger = logger;
}
public void OnGet() {
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}

View File

@ -0,0 +1,88 @@
@page
@using Microsoft.AspNetCore.Http
@using bahnplan.web.database
@using System.Linq
@model IndexModel
@{
ViewData["Title"] = "Home";
}
<div class="text-center">
@if (HttpContext.Session.GetString("authorized") != "true") {
<h1 class="display-4">Welcome</h1>
<p>Please log in to see your personal plan.</p>
}
else {
<h1 class="display-4">
Welcome, @Model.AuthorizedUser.Username
</h1>
<p>
Here are your planned trips.
</p>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Date</th>
<th scope="col">Origin</th>
<th scope="col">Via</th>
<th scope="col">Destination</th>
<th scope="col">Actions</th>
<th scope="col">Danger zone</th>
</tr>
</thead>
<tbody>
@{
await using var db = new Database.DbConn();
var trips = db.Trips.Where(p => p.UserId == Model.AuthorizedUser.UserId).ToList();
foreach (var trip in trips.OrderBy(p => db.Legs.First(a => a.TripId == p.TripId).ArrTime)) {
var legs = db.Legs.Where(p => p.TripId == trip.TripId).OrderBy(p => p.DepTime).ToList();
var dates = DateTime.Parse(legs.First().DepTime).Date == DateTime.Parse(legs.Last().DepTime).Date ? legs.First().DepTime.Substring(0, 10) : legs.First().DepTime.Substring(0, 10) + "<br/>" + legs.Last().DepTime.Substring(0, 10);
<tr>
<td>@Html.Raw(dates)</td>
<td>@Html.Raw(legs.First().DepStation.PadRight(30, ' ').Substring(0, 30).Replace(" ", "&nbsp;"))</td>
<td>
@((from index in from leg in legs where leg.TrainType == "placeholder" select legs.IndexOf(leg) select legs[index - 1].ArrStation).ToList().DefaultIfEmpty("-").Aggregate((s1, s2) => $"{s1}, {s2}"))
</td>
<td>@Html.Raw(legs.Last().ArrStation.PadRight(30, ' ').Substring(0, 30).Replace(" ", "&nbsp;"))</td>
<td>
<a class="btn btn-sm btn-primary" href="/Trip?id=@trip.TripId">View</a>
</td>
<td>
<a class="btn btn-sm btn-outline-danger" href="/Delete?item=trip&id=@trip.TripId">Delete Trip</a>
</td>
</tr>
}
}
</tbody>
</table>
<br/>
<div class="d-flex flex-row" style="justify-content: space-between">
<div class="d-flex p-2" style="width: 40%">
<form style="width: 100%" method="GET" action="/Ticket">
<h3>Add trip from ticket</h3>
<br/>
<div class="form-group">
<input type="text" class="form-control" name="order" placeholder="bahn.de order #">
</div>
<div class="form-group">
<input type="text" class="form-control" name="name" placeholder="Last name of traveller">
</div>
<br/>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<div class="d-flex p-2" style="width: 40%">
<form style="width: 100%" method="GET" action="/OEAPI">
<h3>Add trip from oeffisear.ch</h3>
<br/>
<div class="form-group">
<input type="text" class="form-control" name="link" placeholder="oeffisear.ch link / shortcode">
</div>
<br/>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
}
</div>

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
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 {
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);
}
}
}

View File

@ -0,0 +1,52 @@
@page
@using bahnplan.web.database
@using Microsoft.AspNetCore.Http
@model InspectionModel
@{
ViewData["Title"] = "Inspection";
if (HttpContext.Session.GetString("authorized") != "true") {
Response.Redirect("/");
return;
}
}
<p>
Ticket for <b>@Model.Leg.TrainType @Model.Leg.TrainNr</b> from <b>@Model.Leg.DepStation</b> to <b>@Model.Leg.ArrStation</b>, starting @DateTime.Parse(Model.Leg.DepTime).ToString("yyyy-MM-dd HH:mm")
</p>
<img src="@Model.Ticket.TicketQr" alt="Ticketcode"/>
<img src="@Model.Ticket.TicketSecCode" alt="Sichtmerkmal"/>
<br/>
<br/>
@Model.Ticket.TicketInfo
<br/>
<br/>
@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)) {
var card = db.Cards.First(p => p.Value == 50 && p.Traveller == Model.Ticket.Traveller);
<img src="@card.CardQr" alt="Ticketcode"/>
<img src="@card.CardSecCode" alt="Sichtmerkmal"/>
<img style="margin: -50px; height: 450px; transform: rotate(-90deg); position: relative; left: 130px" src='data:image/svg+xml;base64,@card.CardImage.Base64Encode()' alt="Bahncardimage"/>
}
else {
<div class="alert alert-warning" role="alert">
I would show your BahnCard but you haven't added a card matching the value and name of the ticket yet. <a href="/Cards">You can do that now</a>.
</div>
}
}
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)) {
var card = db.Cards.First(p => p.Value == 25 && p.Traveller == Model.Ticket.Traveller);
<img src="@card.CardQr" alt="Ticketcode"/>
<img src="@card.CardSecCode" alt="Sichtmerkmal"/>
<img style="margin: -50px; height: 450px; transform: rotate(-90deg); position: relative; left: 130px" src='data:image/svg+xml;base64,@card.CardImage.Base64Encode()' alt="Bahncardimage"/>
}
else {
<div class="alert alert-warning" role="alert">
I would show your BahnCard but you haven't added a card matching the value and name of the ticket yet. <a href="/Cards">You can do that now</a>.
</div>
}
}

View File

@ -0,0 +1,22 @@
using System.Collections.Generic;
using System.Linq;
using bahnplan.web.database;
using bahnplan.web.database.Tables;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace bahnplan.web.Pages {
public class InspectionModel : PageModel {
public Ticket Ticket;
public Leg Leg;
public void OnGet() {
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"]));
}
}
}