using System.Web;

using BeWo.Data.Entities;

namespace BeWo.Data
{
    public static class SessionFacade
    {
        public static ApplicationUser LoggedInUser
        {
            get
            {
                return HttpContext.Current.Session["apuser"] as ApplicationUser;
            }

            set
            {
                HttpContext.Current.Session["apuser"] = value;
            }
        }

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