예제 #1
0
        private void CacheSession(string responseString)
        {
            var accessToken = _deserializer.ParseAccessTokenFromLoginResult(responseString);
            var accessTokenExpirationDate = _deserializer.ParseAccessTokenExpiryFromLoginResult(responseString);
            var userId       = _deserializer.ParseUserIdFromLoginResult(responseString);
            var transportUrl = _deserializer.ParseTransportUrlFromResult(responseString);

            _sessionProvider.SetSession(transportUrl, userId, accessToken, accessTokenExpirationDate);
        }
예제 #2
0
        /// <summary>
        /// Taking the current request, find a relevant Phone Manager record to display to the user
        /// </summary>
        /// <returns></returns>
        public OutputModel ProcessRequest()
        {
            // check for active phone manager session
            var returnResult = _sessionProvider.GetSession();

            if (returnResult?.IsValid() ?? false)
            {
                return(returnResult); // valid phone manager session exists so return it. No need to continue with next steps
            }
            // load exisiting cookie if it exisits, null if not
            var exisitingCookie = _cookieProvider.GetCookie();

            // if there is a valid cookie and the GlobalDisableOverwritePersistingItems admin setting is set then we don't need to look  For matching records in the system, we can just use the cookie info.
            bool lookForMatchingRecord = true;

            if ((exisitingCookie?.Model?.IsValid() ?? false) && (_repository.GetDefaultSettings()?.GlobalDisableOverwritePersistingItems ?? false))
            {
                lookForMatchingRecord = false;
            }

            // try and find a relevant phone number from the phone manager records based on the criteria's. Null if none found
            var foundRecord = (lookForMatchingRecord) ? FindMatchingPhoneManagerPhoneNumberUsingGatheredRequestInfo() : null;

            // pass all available data into the method which decides which data to use
            var logicBox = ProcessAllPotentialCandidatePhoneNumbers(exisitingCookie, foundRecord);

            if (logicBox.OutputCookieHolder != null)
            {
                _cookieProvider.SetCookie(logicBox.OutputCookieHolder);
            }

            // save session
            _sessionProvider.SetSession(logicBox.OutputModelResult);

            return(logicBox.OutputModelResult);
        }