Ejemplo n.º 1
0
        public SessionDataResponse GetSessionData(string authenticationId, string sessionId)
        {
            var response = new SessionDataResponse();
            using (new ApplicationContextScope(new ApplicationContext()))
            {
                ApplicationContext.SetSessionId(sessionId);
                try
                {
                    ISessionProvider sessionProvider = SessionProviderFactory.GetSessionProvider();
                    string errorMessage;
                    Core.Model.SessionData data = sessionProvider.GetSession(authenticationId, sessionId,
                                                                             out errorMessage);

                    if (data != null)
                    {
                        response.SessionData = data.ToDataContract();
                        response.IsSuccess = true;
                    }
                    else
                    {
                        response.ErrorMessage = errorMessage;
                    }
                }
                catch (Exception ex)
                {
                    response.ErrorMessage = "Something is not quite right here. Please try again later.";
                    Logger.LogException(ex, Source, "GetSessionData", Severity.Trace);
                }
            }
            return response;
        }
Ejemplo n.º 2
0
 public SessionDataResponse UpdateSessionData(string sessionId, SessionData session)
 {
     var response = new SessionDataResponse();
     try
     {
         using (new ApplicationContextScope(new ApplicationContext()))
         {
             ApplicationContext.SetSessionId(sessionId);
             if (session != null && !string.IsNullOrEmpty(session.AuthenticationId) &&
                 !string.IsNullOrEmpty(session.SessionId))
             {
                 IAuthenticationProvider authenticationProvider =
                     AuthenticationProviderFactory.GetAuthenticationProvider();
                 ISessionProvider sessionProvider = SessionProviderFactory.GetSessionProvider();
                 string error;
                 Core.Model.SessionData sessionModel = sessionProvider.GetSession(session.AuthenticationId,
                                                                                  session.SessionId, out error);
                 if (authenticationProvider.Validate(session.AuthenticationId) && sessionModel != null)
                 {
                     sessionProvider.UpdateSession(session.SessionId, session.AuthenticationId, session.ToModel(),
                                                   out error);
                 }
                 else
                 {
                     response.ErrorMessage = "Unauthorised user! Please SignIn or SignUp";
                 }
                 response.ErrorMessage = error;
                 if (string.IsNullOrEmpty(response.ErrorMessage))
                 {
                     response.IsSuccess = true;
                     response.SessionData = session;
                 }
                 else
                     response.IsSuccess = false;
             }
         }
         return response;
     }
     catch (Exception ex)
     {
         response.ErrorMessage = "Something is not quite right here. Please try again later.";
         Logger.LogException(ex, Source, "GetSessionData", Severity.Trace);
     }
     return response;
 }