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; }
public SessionDataResponse UpdateSessionData(string sessionId, SessionData sessionData) { using (new ApplicationContextScope(new ApplicationContext())) { ApplicationContext.Current.Items["SessionId"] = sessionId; try { var sessionChannelFactory = new WebChannelFactory<ISessionServiceRest>( Configuration.SessionServiceConfigurationName); ISessionServiceRest sessionChannel = sessionChannelFactory.CreateChannel(); if (sessionChannel is IContextChannel) using (new OperationContextScope(sessionChannel as IContextChannel)) { WebOperationContext.Current.OutgoingRequest.Headers.Add("X-MethodName", "UpdateSessionData"); return sessionChannel.UpdateSessionData(sessionId, sessionData); } } catch (Exception exception) { Logger.LogException(exception, Source, "UpdateSessionData", Severity.Major); } } return null; }