using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.RazorPages;
using trainav.web.database;
using trainav.web.database.Tables;

namespace trainav.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);
	}
}