fix oeffisearch; add support for return tickets

This commit is contained in:
Laura Hausmann 2020-06-15 02:52:44 +02:00
parent e4ad77461a
commit b443f2125b
Signed by: zotan
GPG key ID: 5EC1D38FFC321311
3 changed files with 40 additions and 8 deletions

View file

@ -94,12 +94,12 @@ namespace bahnplan.web.JSON {
}
public class Posinfolist {
[J("posinfo", NullValueHandling = NV.Ignore)]
public PosinfoElement Posinfo { get; set; }
[J("posinfo", NullValueHandling = NV.Ignore), JsonConverter(typeof(SingleOrArrayConverter<PosinfoElement>))]
public List<PosinfoElement> Posinfo { get; set; }
}
public class FluffyChildlist {
[J("posinfo", NullValueHandling = NV.Ignore)]
[J("posinfo", NullValueHandling = NV.Ignore), JsonConverter(typeof(SingleOrArrayConverter<PosinfoElement>))]
public List<PosinfoElement> Posinfo { get; set; }
}
@ -136,8 +136,8 @@ namespace bahnplan.web.JSON {
}
public class PurpleChildlist {
[J("posinfo", NullValueHandling = NV.Ignore)]
public PurplePosinfo Posinfo { get; set; }
[J("posinfo", NullValueHandling = NV.Ignore), JsonConverter(typeof(SingleOrArrayConverter<PurplePosinfo>))]
public List<PurplePosinfo> Posinfo { get; set; }
}
public class PosinfoElement {
@ -231,10 +231,13 @@ namespace bahnplan.web.JSON {
public class Schedulelist {
[J("out", NullValueHandling = NV.Ignore)]
public Out Out { get; set; }
public Journey Out { get; set; }
[J("ret", NullValueHandling = NV.Ignore)]
public Journey Ret { get; set; }
}
public class Out {
public class Journey {
[J("txt", NullValueHandling = NV.Ignore)]
public string Txt { get; set; }

View file

@ -39,7 +39,7 @@ namespace bahnplan.web.Pages {
? int.Parse(Request.Query["tripid"])
: db.InsertWithInt32Identity(new Trip {UserId = int.Parse(HttpContext.Session.GetString("uid"))});
foreach (var journey in parsed.Data.Journeys[jid].Legs) {
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();

View file

@ -105,6 +105,35 @@ namespace bahnplan.web.Pages {
});
}
if (parsed.Rporderdetails.Order.Schedulelist.Ret != null)
foreach (var leg in parsed.Rporderdetails.Order.Schedulelist.Ret.Trainlist.Train) {
db.InsertWithInt32Identity(new Leg {
TripId = tripId,
UserId = int.Parse(HttpContext.Session.GetString("uid")),
TrainType = leg.Gattung,
TrainNr = int.Parse(leg.Zugnummer),
ArrStation = leg.Arr.Name,
ArrStationId = int.Parse(leg.Arr.BhfNr),
ArrTime = leg.Arr.Date.Replace("00:00:00", leg.Arr.Time),
DepStation = leg.Dep.Name,
DepStationId = int.Parse(leg.Dep.BhfNr),
DepTime = leg.Dep.Date.Replace("00:00:00", leg.Dep.Time),
TicketId = ticketId
});
db.InsertWithInt32Identity(new TicketLeg {
TicketId = ticketId,
TrainType = leg.Gattung,
TrainNr = int.Parse(leg.Zugnummer),
ArrStation = leg.Arr.Name,
ArrStationId = int.Parse(leg.Arr.BhfNr),
ArrTime = leg.Arr.Date.Replace("00:00:00", leg.Arr.Time),
DepStation = leg.Dep.Name,
DepStationId = int.Parse(leg.Dep.BhfNr),
DepTime = leg.Dep.Date.Replace("00:00:00", leg.Dep.Time)
});
}
TripId = tripId;
}
}