Files
BeWoPlaner/Data/SessionFacade.cs

65 lines
1.6 KiB
C#

using System.Web;
using BeWo.Data.Access;
using BeWo.Data.Entities;
namespace BeWo.Data
{
public static class SessionFacade
{
public static long? LoggedInUserOid
{
get => HttpContext.Current.Session["LoggedInUserOid"] as long?;
set => HttpContext.Current.Session["LoggedInUserOid"] = value;
}
//public static UserDC LoggedInUserDC
//{
// get
// {
// return HttpContext.Current.Session["apuser"] as UserDC;
// }
// set
// {
// HttpContext.Current.Session["apuser"] = value;
// }
//}
public static ApplicationUser LoggedInUser
{
get
{
if (LoggedInUserOid.HasValue)
{
return DAOFactory.GenericDAO.LoadByID<ApplicationUser>(LoggedInUserOid.Value);
}
return null;
}
}
public static string Tenant
{
get
{
return HttpContext.Current.Session["tenant"] as string;
}
set
{
HttpContext.Current.Session["tenant"] = value;
}
}
public static bool IsUserLoggedIn()
{
return LoggedInUser != null;
}
public static void LogUserOut()
{
HttpContext.Current.Session["apuser"] = null;
HttpContext.Current.Session.Abandon();
}
}
}