Code cleanup

This commit is contained in:
Laura Hausmann 2022-05-03 00:20:02 +02:00
parent ec16ec5def
commit 6ab3774228
Signed by: zotan
GPG key ID: D044E84C5BE01605
28 changed files with 699 additions and 721 deletions

View file

@ -1,15 +1,16 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Mvc;
namespace trainav.web.Controllers {
[ApiController, Route("api/[controller]")]
public class TestController : ControllerBase {
[HttpGet]
public ApiResponse Get() => new ApiResponse("test", 4);
}
namespace trainav.web.Controllers;
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")]
public class ApiResponse {
[ApiController, Route("api/[controller]")]
public class TestController : ControllerBase {
[HttpGet]
public ApiResponse Get() => new("test", 4);
}
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")]
public class ApiResponse {
public ApiResponse(string string1, int int1) {
String1 = string1;
Int1 = int1;
@ -17,5 +18,4 @@ namespace trainav.web.Controllers {
public string String1 { get; }
public int Int1 { get; }
}
}

View file

@ -6,8 +6,9 @@ using LinqToDB.Data;
using trainav.web.database;
using trainav.web.database.Tables;
namespace trainav.web {
public static class Migrations {
namespace trainav.web;
public static class Migrations {
private const int DbVer = 1;
private static readonly List<Migration> _migrations = new() {
@ -101,5 +102,4 @@ namespace trainav.web {
db.Execute(_sql);
}
}
}
}

View file

@ -11,19 +11,18 @@ using trainav.web.database.Tables;
using trainav.web.JSON.CardResponse;
using trainav.web.JSON.ListOrdersResponse;
namespace trainav.web.Pages {
public class CardModel : PageModel {
namespace trainav.web.Pages;
public class CardModel : PageModel {
public void OnPost() {
if (HttpContext.Session.GetString("authorized") != "true")
return;
using var db = new Database.DbConn();
var request = new XDocument(new XElement("rqorderheadlist",
new XElement("rqheader", new XAttribute("ts", "2020-02-19T15:59:00"), new XAttribute("l", "de"),
new XAttribute("v", "19120000"), new XAttribute("d", "iPad7,5"),
new XAttribute("os", "iOS_13.3.1"), new XAttribute("app", "NAVIGATOR")),
new XElement("authlogin", new XAttribute("user", Request.Form["user"]),
new XAttribute("pw", Request.Form["pass"]),
new XElement("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);
@ -34,11 +33,10 @@ namespace trainav.web.Pages {
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();
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();
@ -64,5 +62,4 @@ namespace trainav.web.Pages {
});
}
}
}
}

View file

@ -11,8 +11,9 @@ using trainav.web.database;
using trainav.web.database.Tables;
using trainav.web.JSON.CardResponse;
namespace trainav.web.Pages {
public class CardsModel : PageModel {
namespace trainav.web.Pages;
public class CardsModel : PageModel {
public List<Card> Cards;
public void OnGet() {
@ -28,9 +29,8 @@ namespace trainav.web.Pages {
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 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);
@ -51,5 +51,4 @@ namespace trainav.web.Pages {
Cards = db.Cards.Where(p => p.UserId == int.Parse(HttpContext.Session.GetString("uid"))).ToList();
}
}
}

View file

@ -5,8 +5,9 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using trainav.web.database;
using trainav.web.database.Tables;
namespace trainav.web.Pages {
public class DeleteModel : PageModel {
namespace trainav.web.Pages;
public class DeleteModel : PageModel {
public User AuthorizedUser;
public void OnGet() {
@ -48,19 +49,16 @@ namespace trainav.web.Pages {
db.Delete(db.Legs.Where(p => p.TripId == tripid).OrderByDescending(p => p.DepTime).First());
var failsafe = false;
foreach (var failsafeleg in db.Legs.Where(p => p.TripId == tripid).OrderBy(p => p.DepTime).ToList()) {
foreach (var failsafeleg in db.Legs.Where(p => p.TripId == tripid).OrderBy(p => p.DepTime).ToList())
if (failsafeleg.DepTime.EndsWith("placeholder")) {
if (failsafe == false) {
if (failsafe == false)
failsafe = true;
}
else {
else
db.Legs.Delete(p => p.LegId == failsafeleg.LegId);
}
}
else {
failsafe = false;
}
}
break;
}
@ -82,5 +80,4 @@ namespace trainav.web.Pages {
}
}
}
}
}

View file

@ -3,9 +3,10 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
namespace trainav.web.Pages {
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public class ErrorModel : PageModel {
namespace trainav.web.Pages;
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public class ErrorModel : PageModel {
private readonly ILogger<ErrorModel> _logger;
public ErrorModel(ILogger<ErrorModel> logger) => _logger = logger;
@ -17,5 +18,4 @@ namespace trainav.web.Pages {
public void OnGet() {
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}

View file

@ -14,8 +14,9 @@ using trainav.web.database;
using trainav.web.database.Tables;
using Calendar = Ical.Net.Calendar;
namespace trainav.web.Pages {
public class GenIcs : PageModel {
namespace trainav.web.Pages;
public class GenIcs : PageModel {
public string IcsOutput;
public List<Leg> Legs;
public new string User;
@ -47,28 +48,20 @@ namespace trainav.web.Pages {
var calendar = new Calendar();
foreach (var leg in Legs.Where(p => p.TrainType != "placeholder")) {
var depst = ds100Mapping.Where(p => p.Station == leg.DepStation)
.DefaultIfEmpty(new Ds100object {Station = leg.DepStation, Ds100 = leg.DepStation})
.First()
.Ds100;
var arrst = ds100Mapping.Where(p => p.Station == leg.ArrStation)
.DefaultIfEmpty(new Ds100object {Station = leg.ArrStation, Ds100 = leg.ArrStation})
.First()
.Ds100;
var depst = ds100Mapping.Where(p => p.Station == leg.DepStation).DefaultIfEmpty(new Ds100object { Station = leg.DepStation, Ds100 = leg.DepStation }).First().Ds100;
var arrst = ds100Mapping.Where(p => p.Station == leg.ArrStation).DefaultIfEmpty(new Ds100object { Station = leg.ArrStation, Ds100 = leg.ArrStation }).First().Ds100;
var title = $"{depst} -> {arrst} ({leg.TrainType} {leg.TrainNr})";
var e = new CalendarEvent {
Summary = title, Start = new CalDateTime(DateTime.Parse(leg.DepTime)), End = new CalDateTime(DateTime.Parse(leg.ArrTime))
};
var e = new CalendarEvent { Summary = title, Start = new CalDateTime(DateTime.Parse(leg.DepTime)), End = new CalDateTime(DateTime.Parse(leg.ArrTime)) };
if (!string.IsNullOrWhiteSpace(leg.Comment))
e.Description =
leg.Comment
e.Description = leg.Comment
+ "\n"
+ "\n"
+ $"https://marudor.de/details/{leg.TrainType}{leg.TrainNr}/{DateTime.Parse(leg.DepTime).ToUniversalTime().Subtract(new DateTime(1970, 1, 1)).TotalSeconds}000/?station={leg.DepStationId}";
else
e.Description = $"https://marudor.de/details/{leg.TrainType}{leg.TrainNr}/{DateTime.Parse(leg.DepTime).ToUniversalTime().Subtract(new DateTime(1970, 1, 1)).TotalSeconds}000/?station={leg.DepStationId}";
e.Description =
$"https://marudor.de/details/{leg.TrainType}{leg.TrainNr}/{DateTime.Parse(leg.DepTime).ToUniversalTime().Subtract(new DateTime(1970, 1, 1)).TotalSeconds}000/?station={leg.DepStationId}";
calendar.Events.Add(e);
}
@ -100,5 +93,4 @@ namespace trainav.web.Pages {
[Name("Aufgabenträger")] public string Verkehrsverbund { get; set; }
}
}
}

View file

@ -4,8 +4,9 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using trainav.web.database;
using trainav.web.database.Tables;
namespace trainav.web.Pages {
public class IndexModel : PageModel {
namespace trainav.web.Pages;
public class IndexModel : PageModel {
public User AuthorizedUser;
public void OnGet() {
@ -16,5 +17,4 @@ namespace trainav.web.Pages {
using var db = new Database.DbConn();
AuthorizedUser = db.Users.FirstOrDefault(p => p.UserId == uid);
}
}
}

View file

@ -6,8 +6,9 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using trainav.web.database;
using trainav.web.database.Tables;
namespace trainav.web.Pages {
public class InspectionModel : PageModel {
namespace trainav.web.Pages;
public class InspectionModel : PageModel {
public Leg Leg;
public Ticket Ticket;
@ -25,5 +26,4 @@ namespace trainav.web.Pages {
if (!Ticket.TicketSecCode.StartsWith("data:image/png"))
Ticket.TicketSecCode = Encoding.UTF8.GetString(Convert.FromBase64String(Ticket.TicketSecCode));
}
}
}

View file

@ -7,8 +7,9 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.RazorPages;
using trainav.web.database;
namespace trainav.web.Pages {
public class LoginModel : PageModel {
namespace trainav.web.Pages;
public class LoginModel : PageModel {
public void OnPost() {
if (!Request.HasFormContentType || string.IsNullOrWhiteSpace(Request.Form["user"]) || string.IsNullOrWhiteSpace(Request.Form["pass"]))
return;
@ -24,9 +25,9 @@ namespace trainav.web.Pages {
//TODO
}
}
}
public static class StringExtensions {
public static class StringExtensions {
public static string Sha256(this string rawData) {
// Create a SHA256
using var sha256Hash = SHA256.Create();
@ -49,5 +50,4 @@ namespace trainav.web.Pages {
public static string UrlEncode(this string plainText) => HttpUtility.UrlEncode(plainText);
public static string Delimit(this string input, int max) => input.PadRight(max, ' ').Substring(0, max).TrimEnd();
}
}

View file

@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace trainav.web.Pages {
public class LogoutModel : PageModel {
namespace trainav.web.Pages;
public class LogoutModel : PageModel {
public void OnGet() {
HttpContext.Session.Clear();
}
}
}

View file

@ -12,8 +12,9 @@ using Leg = trainav.web.database.Tables.Leg;
// ReSharper disable PossibleInvalidOperationException
namespace trainav.web.Pages {
public class OEAPIModel : PageModel {
namespace trainav.web.Pages;
public class OEAPIModel : PageModel {
public int TripId;
public void OnGet() {
@ -23,12 +24,14 @@ namespace trainav.web.Pages {
var link = Request.Query["link"].ToString();
var shortcode = link;
var oepage = "oeffisear.ch";
if (link.Contains("oeffisear.ch"))
if (link.Contains("oeffisear.ch")) {
shortcode = link.Split("/#/").Last();
}
else if (link.Contains("transit.ztn.sh")) {
shortcode = link.Split("/#/").Last();
oepage = "transit.ztn.sh";
}
var jid = shortcode.Split("/").Last();
shortcode = shortcode.Split("/").First();
@ -43,20 +46,21 @@ namespace trainav.web.Pages {
var tripId = Request.Query["action"] == "addleg"
? int.Parse(Request.Query["tripid"])
: db.InsertWithInt32Identity(new Trip {UserId = int.Parse(HttpContext.Session.GetString("uid"))});
: db.InsertWithInt32Identity(new Trip { UserId = int.Parse(HttpContext.Session.GetString("uid")) });
foreach (var journey in parsed.Data.Journeys[jid].Legs.Where(p => p.IsTransfer != true && p.IsWalking != true)) {
var arrtime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
var deptime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
arrtime = arrtime.AddSeconds((long) journey.Arrival.PlannedTime).ToLocalTime();
deptime = deptime.AddSeconds((long) journey.Departure.PlannedTime).ToLocalTime();
arrtime = arrtime.AddSeconds((long)journey.Arrival.PlannedTime).ToLocalTime();
deptime = deptime.AddSeconds((long)journey.Departure.PlannedTime).ToLocalTime();
var trainNo = int.Parse(journey.Line.TripNum);
if (trainNo == 0) {
var extractedTrainNo = Regex.Match(journey.Line.Name, @"\d+").Value;
if (extractedTrainNo.Length > 0)
trainNo = int.Parse(extractedTrainNo);
}
db.InsertWithInt32Identity(new database.Tables.Leg {
db.InsertWithInt32Identity(new Leg {
TripId = tripId,
UserId = int.Parse(HttpContext.Session.GetString("uid")),
TrainType = journey.Line.ProductName,
@ -72,5 +76,4 @@ namespace trainav.web.Pages {
TripId = tripId;
}
}
}

View file

@ -4,8 +4,9 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using trainav.web.database;
using trainav.web.database.Tables;
namespace trainav.web.Pages {
public class PlainModel : PageModel {
namespace trainav.web.Pages;
public class PlainModel : PageModel {
public User AuthorizedUser;
public void OnGet() {
@ -16,5 +17,4 @@ namespace trainav.web.Pages {
using var db = new Database.DbConn();
AuthorizedUser = db.Users.FirstOrDefault(p => p.UserId == uid);
}
}
}

View file

@ -1,12 +1,12 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
namespace trainav.web.Pages {
public class PrivacyModel : PageModel {
namespace trainav.web.Pages;
public class PrivacyModel : PageModel {
private readonly ILogger<PrivacyModel> _logger;
public PrivacyModel(ILogger<PrivacyModel> logger) => _logger = logger;
public void OnGet() { }
}
}

View file

@ -5,8 +5,9 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using trainav.web.database;
using trainav.web.database.Tables;
namespace trainav.web.Pages {
public class RegisterModel : PageModel {
namespace trainav.web.Pages;
public class RegisterModel : PageModel {
public void OnPost() {
if (!Request.HasFormContentType
|| string.IsNullOrWhiteSpace(Request.Form["user"])
@ -22,10 +23,9 @@ namespace trainav.web.Pages {
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");
}
}
}

View file

@ -4,8 +4,9 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using trainav.web.database;
using trainav.web.database.Tables;
namespace trainav.web.Pages {
public class SharedTripModel : PageModel {
namespace trainav.web.Pages;
public class SharedTripModel : PageModel {
public List<Leg> Legs;
public bool RedirToIndex;
public new string User;
@ -23,5 +24,4 @@ namespace trainav.web.Pages {
if (Request.Query["user"] != User)
RedirToIndex = true;
}
}
}

View file

@ -6,8 +6,9 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using trainav.web.database;
using trainav.web.database.Tables;
namespace trainav.web.Pages {
public class TripModel : PageModel {
namespace trainav.web.Pages;
public class TripModel : PageModel {
public List<Leg> Legs;
public bool RedirToIndex;
public new string User;
@ -63,5 +64,4 @@ namespace trainav.web.Pages {
db.Update(leg);
}
}
}

View file

@ -6,8 +6,9 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using trainav.web.database;
namespace trainav.web {
public class Program {
namespace trainav.web;
public class Program {
public static void Main(string[] args) {
DataConnection.DefaultSettings = new Database.Settings();
Configuration.Linq.AllowMultipleQuery = true;
@ -19,7 +20,5 @@ namespace trainav.web {
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
}
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
}

View file

@ -5,8 +5,9 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace trainav.web {
public class Startup {
namespace trainav.web;
public class Startup {
public Startup(IConfiguration configuration) => Configuration = configuration;
public IConfiguration Configuration { get; }
@ -62,5 +63,4 @@ namespace trainav.web {
endpoints.MapControllers();
});
}
}
}

View file

@ -1,8 +1,8 @@
using System.IO;
namespace trainav.web {
public class Variables {
namespace trainav.web;
public class Variables {
public const string DataDir = "data";
public static readonly string TicketDir = Path.Combine(DataDir, "tickets");
}
}

View file

@ -5,8 +5,9 @@ using LinqToDB.Configuration;
using LinqToDB.Data;
using trainav.web.database.Tables;
namespace trainav.web.database {
public class Database {
namespace trainav.web.database;
public class Database {
public class ConnectionStringSettings : IConnectionStringSettings {
public string ConnectionString { get; set; }
public string Name { get; set; }
@ -36,5 +37,4 @@ namespace trainav.web.database {
public ITable<Trip> Trips => GetTable<Trip>();
public ITable<Card> Cards => GetTable<Card>();
}
}
}

View file

@ -1,10 +1,10 @@
using LinqToDB.Mapping;
namespace trainav.web.database.Tables {
[Table(Name = "Cards")]
public class Card {
[Column(Name = "CardID"), PrimaryKey, Identity, NotNull]
public int CardId { get; set; }
namespace trainav.web.database.Tables;
[Table(Name = "Cards")]
public class Card {
[Column(Name = "CardID"), PrimaryKey, Identity, NotNull] public int CardId { get; set; }
[Column(Name = "OrderID"), NotNull] public string OrderId { get; set; }
@ -33,5 +33,4 @@ namespace trainav.web.database.Tables {
[Column(Name = "QRValidFrom")] public string QrValidFrom { get; set; }
[Column(Name = "QRValidTo")] public string QrValidTo { get; set; }
}
}

View file

@ -1,9 +1,9 @@
using LinqToDB.Mapping;
namespace trainav.web.database.Tables {
[Table(Name = "DbInfo")]
public class DbInfo {
namespace trainav.web.database.Tables;
[Table(Name = "DbInfo")]
public class DbInfo {
[Column(Name = "ID"), PrimaryKey, Identity, NotNull] public int Id { get; set; }
[Column(Name = "DbVer"), NotNull] public int DbVer { get; set; }
}
}

View file

@ -1,10 +1,10 @@
using LinqToDB.Mapping;
namespace trainav.web.database.Tables {
[Table(Name = "Legs")]
public class Leg {
[Column(Name = "LegID"), PrimaryKey, Identity, NotNull]
public int LegId { get; set; }
namespace trainav.web.database.Tables;
[Table(Name = "Legs")]
public class Leg {
[Column(Name = "LegID"), PrimaryKey, Identity, NotNull] public int LegId { get; set; }
[Column(Name = "TripID"), NotNull] public int TripId { get; set; }
@ -14,15 +14,13 @@ namespace trainav.web.database.Tables {
[Column(Name = "TrainNr"), NotNull] public int TrainNr { get; set; }
[Column(Name = "DepStationID"), NotNull]
public int DepStationId { get; set; }
[Column(Name = "DepStationID"), NotNull] public int DepStationId { get; set; }
[Column(Name = "DepStation"), NotNull] public string DepStation { get; set; }
[Column(Name = "DepTime"), NotNull] public string DepTime { get; set; }
[Column(Name = "ArrStationID"), NotNull]
public int ArrStationId { get; set; }
[Column(Name = "ArrStationID"), NotNull] public int ArrStationId { get; set; }
[Column(Name = "ArrStation"), NotNull] public string ArrStation { get; set; }
@ -31,5 +29,4 @@ namespace trainav.web.database.Tables {
[Column(Name = "TicketID")] public int TicketId { get; set; }
[Column(Name = "Comment")] public string Comment { get; set; }
}
}

View file

@ -1,8 +1,9 @@
using LinqToDB.Mapping;
namespace trainav.web.database.Tables {
[Table(Name = "Tickets")]
public class Ticket {
namespace trainav.web.database.Tables;
[Table(Name = "Tickets")]
public class Ticket {
[Column(Name = "TicketID"), PrimaryKey, Identity, NotNull] public int TicketId { get; set; }
[Column(Name = "OrderID"), NotNull] public string OrderId { get; set; }
@ -18,5 +19,4 @@ namespace trainav.web.database.Tables {
[Column(Name = "TicketPkPass")] public string TicketPkPass { get; set; }
[Column(Name = "Traveller")] public string Traveller { get; set; }
}
}

View file

@ -1,8 +1,9 @@
using LinqToDB.Mapping;
namespace trainav.web.database.Tables {
[Table(Name = "TicketLegs")]
public class TicketLeg {
namespace trainav.web.database.Tables;
[Table(Name = "TicketLegs")]
public class TicketLeg {
[Column(Name = "TicketLegID"), PrimaryKey, Identity, NotNull]
public int TicketLegId { get; set; }
@ -12,18 +13,15 @@ namespace trainav.web.database.Tables {
[Column(Name = "TrainNr"), NotNull] public int TrainNr { get; set; }
[Column(Name = "DepStationID"), NotNull]
public int DepStationId { get; set; }
[Column(Name = "DepStationID"), NotNull] public int DepStationId { get; set; }
[Column(Name = "DepStation"), NotNull] public string DepStation { get; set; }
[Column(Name = "DepTime"), NotNull] public string DepTime { get; set; }
[Column(Name = "ArrStationID"), NotNull]
public int ArrStationId { get; set; }
[Column(Name = "ArrStationID"), NotNull] public int ArrStationId { get; set; }
[Column(Name = "ArrStation"), NotNull] public string ArrStation { get; set; }
[Column(Name = "ArrTime"), NotNull] public string ArrTime { get; set; }
}
}

View file

@ -1,12 +1,10 @@
using LinqToDB.Mapping;
namespace trainav.web.database.Tables {
[Table(Name = "Trips")]
public class Trip {
[Column(Name = "TripID"), PrimaryKey, Identity, NotNull]
public int TripId { get; set; }
namespace trainav.web.database.Tables;
[Column(Name = "UserID"), PrimaryKey, NotNull]
public int UserId { get; set; }
}
[Table(Name = "Trips")]
public class Trip {
[Column(Name = "TripID"), PrimaryKey, Identity, NotNull] public int TripId { get; set; }
[Column(Name = "UserID"), PrimaryKey, NotNull] public int UserId { get; set; }
}

View file

@ -1,13 +1,12 @@
using LinqToDB.Mapping;
namespace trainav.web.database.Tables {
[Table(Name = "Users")]
public class User {
[Column(Name = "UserID"), PrimaryKey, Identity, NotNull]
public int UserId { get; set; }
namespace trainav.web.database.Tables;
[Table(Name = "Users")]
public class User {
[Column(Name = "UserID"), PrimaryKey, Identity, NotNull] public int UserId { get; set; }
[Column(Name = "Username"), NotNull] public string Username { get; set; }
[Column(Name = "Password"), NotNull] public string Password { get; set; }
}
}