public CustomerSummary GetCustomerSummary(string tenantUid, string origin, JwtCustomerDataResponseContent decodedJwt) { var response = (GetCustomerAccountBalanceResponseContent)GetAccountBalance(tenantUid, origin, decodedJwt.CustomerGuid.Value.ToString(), decodedJwt.EncodedToken); if (response.Success) { return(new CustomerSummary { CustomerGuid = decodedJwt.CustomerGuid.Value, CurrencyCode = decodedJwt.CurrencyCode, Balance = new Balance { CurrentBalance = DefaultAllowedValues.DecimalAccuracy(response.Payload.TotalAccountBalance, decodedJwt.CurrencyCode), Bonus = DefaultAllowedValues.DecimalAccuracy(response.Payload.BonusBalance, decodedJwt.CurrencyCode), Withdrawable = DefaultAllowedValues.DecimalAccuracy(response.Payload.WithdrawableBalance, decodedJwt.CurrencyCode), IsLiveBalance = true }, LanguageCode = decodedJwt.LanguageCode, OddsDisplayName = decodedJwt.OddsDisplay, TenantPlatformMapGuid = decodedJwt.TenantPlatformMapGuid, TimeZone = decodedJwt.TimeZone, Username = decodedJwt.Username }); } else { return new CustomerSummary { Username = decodedJwt.Username, CurrencyCode = decodedJwt.CurrencyCode, Balance = new Balance { Bonus = DefaultAllowedValues.DecimalAccuracy(0.00m, decodedJwt.CurrencyCode), CurrentBalance = DefaultAllowedValues.DecimalAccuracy(0.00m, decodedJwt.CurrencyCode), Withdrawable = DefaultAllowedValues.DecimalAccuracy(0.00m, decodedJwt.CurrencyCode), IsLiveBalance = false, BalanceRetrievalFailureMessage = response.Message, Errors = response.Errors }, LanguageCode = decodedJwt.LanguageCode, OddsDisplayName = decodedJwt.OddsDisplay, TimeZone = decodedJwt.TimeZone, TenantPlatformMapGuid = decodedJwt.TenantPlatformMapGuid, CustomerGuid = decodedJwt.CustomerGuid } }; }
public async Task <CustomerSummary> GetCustomerSummaryAsync(string tenantUid, string origin, JwtCustomerDataResponseContent decodedJwt) { var response = (GetCustomerAccountBalanceResponseContent) await GetAccountBalanceAsync(tenantUid, origin, decodedJwt.CustomerGuid.Value.ToString(), decodedJwt.EncodedToken); var payload = response.Payload; return(new CustomerSummary { CustomerGuid = decodedJwt.CustomerGuid.Value, CurrencyCode = decodedJwt.CurrencyCode, Balance = new Balance { CurrentBalance = payload != null?DefaultAllowedValues.DecimalAccuracy(payload.TotalAccountBalance, decodedJwt.CurrencyCode) : DefaultAllowedValues.DecimalAccuracy(0.00m, decodedJwt.CurrencyCode), Bonus = payload != null?DefaultAllowedValues.DecimalAccuracy(payload.BonusBalance, decodedJwt.CurrencyCode) : DefaultAllowedValues.DecimalAccuracy(0.00m, decodedJwt.CurrencyCode), Withdrawable = payload != null?DefaultAllowedValues.DecimalAccuracy(payload.WithdrawableBalance, decodedJwt.CurrencyCode) : DefaultAllowedValues.DecimalAccuracy(0.00m, decodedJwt.CurrencyCode), IsLiveBalance = response.Success }, LanguageCode = decodedJwt.LanguageCode, OddsDisplayName = decodedJwt.OddsDisplay, TenantPlatformMapGuid = decodedJwt.TenantPlatformMapGuid, TimeZone = decodedJwt.TimeZone, Username = decodedJwt.Username }); }
public async Task <ActionResult> TotalCodeAccountPageTemplate() { var accountPage = GetModel <AccountPageViewModel>(CurrentPage); if (!LoginSession.LoggedIn || !accountPage.IsLoggedIn) { return(Redirect("/")); } string domain = Request.Url.ToString(); #if DEBUG domain = $"https://{accountPage.Subdomain}.{accountPage.Domain}"; #endif var origin = domain; var decodedJwt = LoginSession.DecodedJwtToken; var response = (GetCustomerInfoResponseContent)await apiService.GetCustomerInfoAsync(accountPage.TenantUid, origin, LoginSession.Username, LoginSession.Token); if (response.Success) { accountPage.Customer = response.Payload; var walletResponse = (GetCustomerAccountBalanceResponseContent)await apiService.GetAccountBalanceAsync(accountPage.TenantUid, origin, response.Payload.CustomerGuid.Value.ToString(), LoginSession.Token); if (walletResponse.Success) { accountPage.CustomerWallet = new CustomerWallet { TotalAccountBalance = DefaultAllowedValues.DecimalAccuracy(walletResponse.Payload.TotalAccountBalance, decodedJwt.CurrencyCode), BonusBalance = DefaultAllowedValues.DecimalAccuracy(walletResponse.Payload.BonusBalance, decodedJwt.CurrencyCode), WithdrawableBalance = DefaultAllowedValues.DecimalAccuracy(walletResponse.Payload.WithdrawableBalance, decodedJwt.CurrencyCode), CustomerGuid = walletResponse.Payload.CustomerGuid }; } else { accountPage.CustomerWallet = new CustomerWallet { BonusBalance = DefaultAllowedValues.DecimalAccuracy(0.00m, decodedJwt.CurrencyCode), TotalAccountBalance = DefaultAllowedValues.DecimalAccuracy(0.00m, decodedJwt.CurrencyCode), WithdrawableBalance = DefaultAllowedValues.DecimalAccuracy(0.00m, decodedJwt.CurrencyCode), CustomerGuid = response.Payload.CustomerGuid }; } } else { accountPage.Customer = new PayloadContent(); accountPage.CustomerWallet = new CustomerWallet(); ConnectorContext.Logger.Debug(typeof(TotalCodeAccountPageController), JsonConvert.SerializeObject(response)); } //else //{ // // probably token has expired, redirect to home to login again // LoginSession.Logout(); // return Redirect("/"); //} HttpCookie cookie = new HttpCookie("IsAuthenticatedPage"); cookie.Value = "1"; cookie.Expires = DateTime.UtcNow.AddDays(999); HttpContext.Response.Cookies.Add(cookie); return(CurrentTemplate(accountPage)); }