using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Security.Principal;

namespace StaticAppGlobals
{
    /// <summary>
    /// Summary description for BaseUserControl
    /// </summary>
    public class BaseUserControl : System.Web.UI.UserControl
    {
        protected IIdentity UserId = HttpContext.Current.User.Identity;
        //protected CentralTicket cticketservice = new CentralTicket();
        protected DataRetriever cticketservice = new DataRetriever();

        public CentralUserProfile UserProfile
        {
            get 
            {
                try
                {
                    return (CentralUserProfile)HttpContext.Current.Session["UserProfile"];
                }
                catch
                {
                    HttpContext.Current.Session["UserProfile"] = new CentralUserProfile(UserId);
                    return (CentralUserProfile)HttpContext.Current.Session["UserProfile"];
                }
            }
            set 
            {
                HttpContext.Current.Session["UserProfile"] = value;
            }
        }

        public BaseUserControl()
        {
        }

        protected void Page_Load()
        {
            if (UserProfile == null)
                UserProfile = new CentralUserProfile(UserId);
        }
    }
}
