39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using bahnplan.web.database;
|
|
using bahnplan.web.database.Tables;
|
|
using LinqToDB;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
namespace bahnplan.web.Pages {
|
|
public class TripModel : PageModel {
|
|
public List<Leg> Legs;
|
|
|
|
public void OnGet() {
|
|
if (HttpContext.Session.GetString("authorized") != "true") {
|
|
return;
|
|
}
|
|
|
|
using var db = new Database.DbConn();
|
|
if (Request.Query.ContainsKey("separator")) {
|
|
var leg = db.Legs.First(p => p.LegId == int.Parse(Request.Query["legid"]));
|
|
db.Insert(new Leg {
|
|
TripId = int.Parse(Request.Query["id"]),
|
|
UserId = int.Parse(HttpContext.Session.GetString("uid")),
|
|
TrainType = "placeholder",
|
|
TrainNr = int.Parse(Request.Query["legid"]),
|
|
ArrStation = "_",
|
|
ArrStationId = 0,
|
|
ArrTime = "_",
|
|
DepStation = "_",
|
|
DepStationId = 0,
|
|
DepTime = leg.DepTime + "_placeholder",
|
|
});
|
|
return;
|
|
}
|
|
|
|
Legs = db.Legs.Where(p => p.TripId == int.Parse(Request.Query["id"])).OrderBy(p => p.DepTime).ToList();
|
|
}
|
|
}
|
|
} |