public void SetUserToken(string value)
 {
     if (string.IsNullOrWhiteSpace(value) == true)
     {
         value = null;
     }
     this.GetSession()[SessionKeys.ForUserToken()] = value;
 }
        public string GetUserToken()
        {
            var token = this.GetSession()[SessionKeys.ForUserToken()] as string;

            if (string.IsNullOrWhiteSpace(token) == true)
            {
                return(null);
            }
            else
            {
                return(token);
            }
        }
 public void SetUser(APUser user)
 {
     if (user == null)
     {
         this.GetSession()[SessionKeys.ForUser()] = null;
     }
     else
     {
         var serializer = ObjectFactory.Build <IJsonSerializer>();
         var bytes      = serializer.Serialize(user);
         this.GetSession()[SessionKeys.ForUser()] = bytes;
     }
 }
        public APUser GetUser()
        {
            var session   = GetSession();
            var userBytes = session[SessionKeys.ForUser()] as byte[];

            if (userBytes == null || userBytes.Length == 0)
            {
                return(null);
            }
            var serializer = ObjectFactory.Build <IJsonSerializer>();

            return(serializer.Deserialize <APUser>(userBytes));
        }