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 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);
		}
	}
}