private void GetRegistrationText(SiteConfigurationData siteConfig, ConfigurationAgeBand configurationAgeBand, string configurationAgeBandKey, string languageCode, bool registration, Action <IGetAgeBandResult> callback)
    {
        List <string> documentIds = GetAllTextIds(siteConfig, configurationAgeBandKey, registration);

        if (documentIds.Count == 0)
        {
            HandleRequestSuccess(siteConfig, configurationAgeBand, configurationAgeBandKey, registration, new List <RegistrationText>(), callback);
        }
        else
        {
            try
            {
                GetRegistrationTextRequest getRegistrationTextRequest = new GetRegistrationTextRequest();
                getRegistrationTextRequest.LanguageCode = languageCode;
                getRegistrationTextRequest.TextCodes    = documentIds;
                getRegistrationTextRequest.CountryCode  = configurationAgeBand.country;
                getRegistrationTextRequest.AgeBand      = configurationAgeBandKey;
                GetRegistrationTextRequest request = getRegistrationTextRequest;
                IWebCall <GetRegistrationTextRequest, GetRegistrationTextResponse> webCall = webCallFactory.RegistrationTextPost(request);
                webCall.OnResponse += delegate(object sender, WebCallEventArgs <GetRegistrationTextResponse> e)
                {
                    GetRegistrationTextResponse response = e.Response;
                    if (ValidateResponse(response, documentIds))
                    {
                        HandleRequestSuccess(siteConfig, configurationAgeBand, configurationAgeBandKey, registration, response.RegistrationText, callback);
                    }
                    else
                    {
                        callback(new GetAgeBandResult(success: false, null));
                    }
                };
                webCall.OnError += delegate
                {
                    callback(new GetAgeBandResult(success: false, null));
                };
                webCall.Execute();
            }
            catch (Exception arg)
            {
                logger.Critical("Unhandled exception: " + arg);
                callback(new GetAgeBandResult(success: false, null));
            }
        }
    }
Esempio n. 2
0
 public IWebCall <GetRegistrationTextRequest, GetRegistrationTextResponse> RegistrationTextPost(GetRegistrationTextRequest request)
 {
     return(CreateWebCall <GetRegistrationTextRequest, GetRegistrationTextResponse>(HttpMethod.POST, new Uri(host + "/registration/text"), request));
 }