public Response ValidateUserSession(Request request) { if (request == null || string.IsNullOrEmpty(request.SessionId)) return new Response() {IsSucess = false, ErrorMessage = "Invalide session request!"}; Response response = new Response() { IsSucess = true }; try { ICacheProvider cache = CacheProviderFactory.GetCacheProvider(); var session = cache.GetValue(request.SessionId); if (session == null) { response.IsSucess = false; response.ErrorMessage = "Session expired! Please sign in again."; } } catch (Exception ex) { response.IsSucess = false; response.ErrorMessage = "Session expired! Please sign in again."; LoggingDataProviderFactory.GetLoggingDataProvider().LogException(ex, Source, "ValidateUserSession", Model.Severity.Critical); } return response; }
public Response Logout(Request request) { if (request == null || string.IsNullOrEmpty(request.SessionId)) return new Response() { IsSucess = false, ErrorMessage = "Invalide logout request!" }; Response response = new Response() { IsSucess = true }; try { ICacheProvider cache = CacheProviderFactory.GetCacheProvider(); cache.Remove(request.SessionId); } catch (Exception ex) { response.IsSucess = false; response.ErrorMessage = "Logout failed!"; LoggingDataProviderFactory.GetLoggingDataProvider().LogException(ex, Source, "Logout", Model.Severity.Critical); } return response; }