public virtual async Task <StoreViewModel> GetStoreViewModelAsync(GetStoreParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentNullException("scope");
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentNullException("cultureInfo");
            }
            if (string.IsNullOrWhiteSpace(param.StoreNumber))
            {
                throw new ArgumentNullException("storeNumber");
            }
            if (string.IsNullOrWhiteSpace(param.BaseUrl))
            {
                throw new ArgumentNullException("baseUrl");
            }

            var overtureStore = await StoreRepository.GetStoreByNumberAsync(param).ConfigureAwait(false);

            if (overtureStore == null)
            {
                return(null);
            }

            var createVmParam = new CreateStoreViewModelParam
            {
                Store       = overtureStore,
                CultureInfo = param.CultureInfo,
                BaseUrl     = param.BaseUrl,
                SearchPoint = param.SearchPoint
            };
            var storeViewModel = StoreViewModelFactory.CreateStoreViewModel(createVmParam);

            storeViewModel.StructuredData = StoreViewModelFactory.CreateStoreStructuredDataViewModel(createVmParam);

            if (storeViewModel.HasLocation())
            {
                storeViewModel.Context.Add("latitude", storeViewModel.GetLatitude().ToString(CultureInfo.InvariantCulture));
                storeViewModel.Context.Add("longitude", storeViewModel.GetLongitude().ToString(CultureInfo.InvariantCulture));
            }

            return(storeViewModel);
        }
Exemplo n.º 2
0
    //Get Redeem Link
    public string GetRedeemLink(int playerId = 0, string token = "")
    {
        string paramOtp  = "";
        string paramJson = "";

        if (ParseToken(playerId, token))
        {
            GetStoreParam param = new GetStoreParam();
            param.player_id = apiPlayerId;
            param.token     = apiToken;
            param.is_live   = (Congest.DEVELOPMENT ? 0 : 1);
            paramJson       = JsonUtility.ToJson(param);
            paramOtp        = Util.RandomChar(32);
            paramJson       = Digest.Write(paramJson, paramOtp);
        }
        byte[] bytesToEncode = System.Text.Encoding.UTF8.GetBytes(paramJson);
        paramJson = Convert.ToBase64String(bytesToEncode);
        return(Congest.DOMAIN + "redeem/index.php?postid=" + paramOtp + "&postdata=" + paramJson);
    }
Exemplo n.º 3
0
        public virtual async Task <Overture.ServiceModel.Customers.Stores.Store> GetStoreByNumberAsync(GetStoreParam param)
        {
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException("scope");
            }
            if (string.IsNullOrWhiteSpace(param.StoreNumber))
            {
                throw new ArgumentException("storeNumber");
            }

            var cacheKey = new CacheKey(CacheConfigurationCategoryNames.Store)
            {
                Scope = param.Scope
            };

            cacheKey.AppendKeyParts(GETSTOREBYNUMBER_CACHE_KEYPART, param.StoreNumber);

            var request = new GetStoreByNumberRequest()
            {
                ScopeId          = param.Scope,
                Number           = param.StoreNumber,
                IncludeAddresses = param.IncludeAddresses,
                IncludeSchedules = param.IncludeSchedules
            };

            return(await CacheProvider.GetOrAddAsync(cacheKey, () => OvertureClient.SendAsync(request)).ConfigureAwait(false));
        }