public ActionResult TotalCodeCasinoPageTemplate() { var model = GetModel <GamePageViewModel>(CurrentPage); if (Request.QueryString["gameId"] != null) { var origin = TenantHelper.GetCurrentTenantUrl(contentService, model.TenantUid); var gameId = int.Parse(Request.QueryString["gameId"].ToString()); var key = ApiKeyCache.GetByTenantUid(model.TenantUid); var authorization = GetAuthorization(key); var games = apiService.GetGameDataAnonymousArray(model.TenantUid, origin, authorization: authorization.AccessToken); var game = games.SingleOrDefault(x => x.GameId == gameId); if (game != null) { model.HasDemoMode = game.DemoEnabled; model.GameUrl = game.Url; } } else { model.Slider = 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(); } model.Category = "casino"; return(CurrentTemplate(model)); }
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); }