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 Leg    Leg;
		public Ticket Ticket;

		public void OnGet() {
			if (HttpContext.Session.GetString("authorized") != "true")
				return;

			using var db = new Database.DbConn();
			Leg    = db.Legs.First(p => p.LegId == int.Parse(Request.Query["leg"]));
			Ticket = db.Tickets.First(p => p.TicketId == Leg.TicketId);
		}
	}
}