public ActionResult GameIframe()
        {
            string token      = String.Empty;
            var    apiService = new TotalCodeApiService();
            var    page       = Umbraco.Content(CurrentPage.Parent.Id);

            var homePage       = CurrentPage.Root();
            var TenantUid      = homePage.Value <string>("tenantUid");
            var currentCulture = Umbraco.CultureDictionary.Culture.TwoLetterISOLanguageName;

            int gameId; Int32.TryParse(CurrentPage.GetProperty("gameId").Value().ToString(), out gameId);

            HttpCookie tokenCookie = Request.Cookies["token"];

            if (tokenCookie != null)
            {
                token = tokenCookie.Value;
            }
            else
            {
                System.Web.HttpContext.Current.Response.Redirect(page.GetUrl(currentCulture) + "?gameId=" + gameId + "#popup-login");
            }

            System.Web.HttpContext.Current.Response.Redirect(page.GetUrl(currentCulture) + "?gameId=" + gameId);

            string origin = Request.Url.ToString();

            string gameName = CurrentPage.GetProperty("gameName").Value().ToString();

            var game  = (GameByIdResponseContent)apiService.GetGameById(TenantUid, origin, gameId, gameIdentifier: gameName, authorization: token, languageCode: currentCulture);
            var lobby = "";

            if (game != null)
            {
                var gameLobbyUrl = (GameLobbyResponseContent)apiService.GetGameLobby(game.Url, TenantUid, origin, customerToken: token, locale: currentCulture);
                if (gameLobbyUrl.Success)
                {
                    lobby = gameLobbyUrl.Link;
                }
            }

            var result = "<iframe src=\"" + lobby + "\" id=\"game-iframe\" frameborder=\"0\" allowfullscreen></iframe>";

            return(Content(result));
        }
예제 #2
0
        public T Model <T>(T model, IPublishedContent CurrentPage, HttpRequestBase Request) where T : BasePageViewModel
        {
            #region Defaults
            model.ShowProvidersFilter   = true;
            model.ShowSeachFilter       = true;
            model.ShowSubCategoryFilter = true;
            #endregion

            model.Title = model.Content.Name;
            var gameUrl     = string.Empty;
            var category    = string.Empty;
            var subCategory = string.Empty;
            var gameType    = GamePageType.none;
            var origin      = TenantHelper.GetCurrentTenantUrl(contentService, model.TenantUid);
            //var key = ApiKeyCache.GetByTenantUid(model.TenantUid);
            //var authorization = GetAuthorization(key);
            var authorization = ApiAuthorizationCache.GetOrSetAuthorization(model.TenantUid);
            var returnUrl     = model.IsHomePage ? model.RootUrl : $"https://{model.Subdomain}.{model.Domain}";
            //var returnUrl = model.IsHomePage ? model.RootUrl : $"https://{model.Subdomain}.{model.Domain}{model.Content.Url}";

#if DEBUG
            returnUrl = model.IsHomePage ? $"https://{model.Subdomain}.{model.Domain}" : $"https://{model.Subdomain}.{model.Domain}{model.Content.Url}";
#endif
            model.ReturnUrl = returnUrl;

            var gameDetails = AssertGameType(model);
            category = gameDetails.Item1;
            gameType = gameDetails.Item3;

            var games = apiService.GetGameDataAnonymousArray(model.TenantUid, origin, category: category, languageCode: model.CurrentLanguage.TwoLetterISOLanguageName, authorization: authorization.AccessToken);

            if (games != null)
            {
                foreach (var game in games)
                {
                    if (model.Content.Descendant() != null)
                    {
                        game.GamePageUrl = model.Content.Descendants().SingleOrDefault(x => x.HasProperty("gameType") && x.Value <string>("gameType") == game.Category)?.Url;
                    }
                }
            }
            // make sure games is not null

            games = games ?? new List <GameDetails>();

            if (Request.QueryString["gameId"] != null)
            {
                var gameId       = int.Parse(Request.QueryString["gameId"].ToString());
                var gameFromList = games.SingleOrDefault(x => x.GameId == gameId);
                var game         = (GameByIdResponseContent)apiService.GetGameById(model.TenantUid, origin, gameId: gameId, gameIdentifier: gameFromList.GameIdentifier, authorization: authorization.AccessToken);
                if (game != null)
                {
                    model.HasDemoMode = game.DemoEnabled;
                    model.DemoUrl     = game.DemoUrl;
                    model.UrlType     = game.UrlTypeEnum;
                    model.GameMode    = GameMode.Choose;
                    model.GameId      = int.Parse(Request.QueryString["gameId"]);
                    model.GameImage   = game.GameImages.SingleOrDefault(x => x.ImageTypeEnum == ImageType.Full).Url;

                    switch (model.UrlType)
                    {
                    case UrlType.iFrame:
                        model.GameUrl         = $"{game.Url}?id={model.TenantUid}&langId={model.CurrentLanguage.TwoLetterISOLanguageName}&returnUrl={HttpUtility.UrlDecode(CurrentPage.UrlAbsolute())}";
                        model.OpenPopup       = false;
                        model.GameMode        = GameMode.Play;
                        model.GameLoadSuccess = true;
                        break;

                    case UrlType.Session:

                        if (game.DemoEnabled)
                        {
                            model.OpenPopup = true;
                            model.GameMode  = GameMode.Choose;
                        }
                        else
                        {
                            model.GameMode = GameMode.Play;
                        }

                        if (Request.QueryString["mode"] != null)
                        {
                            var mode = Request.QueryString["mode"];
                            if (mode == "demo")
                            {
                                model.GameMode = GameMode.Demo;
                            }
                            if (mode == "play")
                            {
                                model.GameMode = GameMode.Play;
                            }
                            model.OpenPopup = false;
                        }

                        if (game.Category == "Casino" && game.UrlType == 2 && Request.QueryString["mode"] != null)
                        {
                            game.Url     += "&ReturnUrl=" + HttpUtility.UrlDecode(CurrentPage.UrlAbsolute());
                            game.DemoUrl += "&ReturnUrl=" + HttpUtility.UrlDecode(CurrentPage.UrlAbsolute());
                        }
                        if (game.Category == "Casino" && Request.QueryString["mode"] == null)
                        {
                            game.Url     += "?ReturnUrl=" + HttpUtility.UrlDecode(CurrentPage.UrlAbsolute());
                            game.DemoUrl += "?ReturnUrl=" + HttpUtility.UrlDecode(CurrentPage.UrlAbsolute());
                        }

                        string sessionUrl  = game.Url;
                        var    gameModeUrl = game.Url;
                        gameModeUrl = model.GameMode == GameMode.Demo ? game.DemoUrl : game.Url;

                        switch (gameType)
                        {
                        case GamePageType.InPlay:
                            break;

                        case GamePageType.Casino:
                            var gameLobbyUrl = (GameLobbyResponseContent)apiService.GetGameLobby(gameModeUrl, model.TenantUid, origin, LoginSession.Token ?? authorization.AccessToken, model.CurrentLanguage.TwoLetterISOLanguageName, returnUrl);
                            //var gameLobbyUrl = (GameLobbyResponseContent)apiService.GetGameLobby($"{gameModeUrl}&returnUrl={ContentHelper.EncodeUrl(returnUrl)}", model.TenantUid, origin, LoginSession.Token ?? authorization.AccessToken, model.CurrentLanguage.TwoLetterISOLanguageName, returnUrl);
                            if (gameLobbyUrl.Success)
                            {
                                //if (game.GameIdentifier == "Zeppelin")
                                //{
                                //HttpContext.Current.Response.Redirect(gameLobbyUrl.Link);
                                //}
                                sessionUrl            = gameLobbyUrl.Link;
                                model.GameLoadSuccess = true;
                            }

                            break;

                        case GamePageType.LiveCasino:
                            var liveCasinoLobbyUrl = (GameLobbyResponseContent)apiService.GetGameLobby(gameModeUrl, model.TenantUid, origin, LoginSession.Token ?? authorization.AccessToken, model.CurrentLanguage.TwoLetterISOLanguageName, returnUrl);
                            if (liveCasinoLobbyUrl.Success)
                            {
                                sessionUrl            = liveCasinoLobbyUrl.Link;
                                model.GameLoadSuccess = true;
                            }

                            break;

                        case GamePageType.Poker:
                            var pokerLobbyUrl = (PokerLobbyResponseContent)apiService.GetPokerLobby(model.TenantUid, origin, LoginSession.Token ?? authorization.AccessToken, model.CurrentLanguage.TwoLetterISOLanguageName, returnUrl);
                            if (pokerLobbyUrl.Success)
                            {
                                sessionUrl            = pokerLobbyUrl.RedirectUrl;
                                model.ReturnUrl       = returnUrl;
                                model.GameLoadSuccess = true;
                            }
                            break;

                        case GamePageType.Lottery:
                            var lotteryLobbyUrl = (GameLobbyResponseContent)apiService.GetGameLobby(gameModeUrl, model.TenantUid, origin, LoginSession.Token ?? authorization.AccessToken, model.CurrentLanguage.TwoLetterISOLanguageName, returnUrl);
                            if (lotteryLobbyUrl.Success)
                            {
                                sessionUrl            = lotteryLobbyUrl.Link;
                                model.GameLoadSuccess = true;
                            }

                            break;

                        case GamePageType.Vegas:
                            break;

                        case GamePageType.Sport:
                            break;

                        case GamePageType.Board:
                            var boardLobbyUrl = (GameLobbyResponseContent)apiService.GetGameLobby(gameModeUrl, model.TenantUid, origin, LoginSession.Token ?? authorization.AccessToken, model.CurrentLanguage.TwoLetterISOLanguageName, returnUrl);
                            if (boardLobbyUrl.Success)
                            {
                                sessionUrl            = boardLobbyUrl.Link;
                                model.GameLoadSuccess = true;
                            }

                            break;

                        default:
                            break;
                        }
                        model.GameUrl = sessionUrl;
                        break;

                    default:
                        model.GameUrl = string.Empty;
                        break;
                    }
                }
            }

            if (CurrentPage.HasProperty("gameSlider"))
            {
                model.Slider = CurrentPage.HasValue("gameSlider") ? CurrentPage.Value <IEnumerable <IPublishedElement> >("gameSlider")
                               .Select(x => new SliderItem
                {
                    Image       = x.HasValue("sliderItemImage") ? x.GetProperty("sliderItemImage").Value <IPublishedContent>().Url : string.Empty,
                    ButtonLabel = x.HasValue("sliderItemButtonLabel") ? x.GetProperty("sliderItemButtonLabel").GetValue().ToString() : string.Empty,
                    Title       = x.HasValue("sliderItemTitle") ? x.GetProperty("sliderItemTitle").GetValue().ToString() : string.Empty,
                    Subtitle    = x.HasValue("sliderItemSubtitle") ? x.GetProperty("sliderItemSubtitle").GetValue().ToString() : string.Empty,
                    Url         = x.HasValue("sliderItemUrl") ? x.GetProperty("sliderItemUrl").GetValue().ToString() : string.Empty,
                })?.ToList() : new List <SliderItem>();
            }

            if (CurrentPage.HasProperty("bannerSlider"))
            {
                model.Slider = CurrentPage.HasValue("bannerSlider") ? CurrentPage.Value <IEnumerable <IPublishedElement> >("bannerSlider")
                               .Select(x => new SliderItem
                {
                    Image       = x.Value("sliderItemImage") != null ? x.GetProperty("sliderItemImage").Value <IPublishedContent>().Url : string.Empty,
                    ButtonLabel = x.HasValue("sliderItemButtonLabel") ? x.GetProperty("sliderItemButtonLabel").GetValue().ToString() : string.Empty,
                    Title       = x.HasValue("sliderItemTitle") ? x.GetProperty("sliderItemTitle").GetValue().ToString() : string.Empty,
                    Subtitle    = x.HasValue("sliderItemSubtitle") ? x.GetProperty("sliderItemSubtitle").GetValue().ToString() : string.Empty,
                    Url         = x.HasValue("sliderItemUrl") ? x.GetProperty("sliderItemUrl").GetValue().ToString() : string.Empty,
                })?.ToList() : new List <SliderItem>();
            }

            var menuItems = CurrentPage.Children.Where(x => x.GetProperty("pageCustomSvg") != null && x.GetProperty("pageCustomSvg").HasValue())
                            .Select(z => new MenuItem
            {
                Label   = z.Name,
                SvgIcon = "/img/svg/" + z.GetProperty("pageCustomSvg").GetValue().ToString() + ".svg",
                Url     = z.Url
            });

            var orderedMenuIcons = new List <MenuItem>();
            int order            = 0;
            foreach (var item in model.TopMenu)
            {
                var orderedMenuItem = menuItems.SingleOrDefault(x => x.Url.Equals(item.Url));
                if (orderedMenuItem != null)
                {
                    orderedMenuItem.Order = order;
                    orderedMenuIcons.Add(orderedMenuItem);
                    order++;
                }
            }
            model.MenuItems = orderedMenuIcons?.OrderBy(x => x.Order).ToList();

            model.Games    = games;
            model.Category = category;

            var home = TenantHelper.GetCurrentTenantHome(contentService, model.TenantUid);

            model.PlayButtonText = home.GetValue <string>("playButtonText", model.CurrentLanguage.TwoLetterISOLanguageName) ?? string.Empty;
            model.DemoButtonText = home.GetValue <string>("demoButtonText", model.CurrentLanguage.TwoLetterISOLanguageName) ?? string.Empty;
            model.GameMessage    = home.GetValue <string>("gameMessage", model.CurrentLanguage.TwoLetterISOLanguageName) ?? string.Empty;
            model.GameAgreeText  = home.GetValue <string>("gameAgreeText", model.CurrentLanguage.TwoLetterISOLanguageName) ?? string.Empty;
            model.PageImages     = home.GetValue <IEnumerable <IPublishedElement> >("demoPageImages", model.CurrentLanguage.TwoLetterISOLanguageName) ?? Enumerable.Empty <IPublishedElement>();

            return(model);
        }