public string DisableTenant(string tenantUid)
        {
            var tenantNode = TenantHelper.GetCurrentTenantHome(contentService, tenantUid.ToString());

            if (tenantNode == null)
            {
                throw new TenantException(ExceptionCode.TenantNotFound.CodeToString(), ExceptionCode.TenantNotFound, tenantUid.ToString());
            }
            if (tenantNode.GetValue <string>("tenantStatus").Equals(DISABLED))
            {
                throw new TenantException(ExceptionCode.TenantAlreadyDisabled.CodeToString(), ExceptionCode.TenantAlreadyDisabled, tenantUid);
            }

            try
            {
                tenantNode.SetValue("tenantStatus", DISABLED);
                contentService.Save(tenantNode);
                contentService.Unpublish(tenantNode);
                ConnectorContext.AuditService.Add(AuditType.Unpublish, -1, tenantNode.Id, "Content Node", $"ContentNode for {tenantUid} has been disabled");
                return(tenantUid.ToString());
            }
            catch (Exception ex)
            {
                logger.Error(typeof(HomeContentNode), ex.Message);
                logger.Error(typeof(HomeContentNode), ex.StackTrace);
                throw;
            }
        }
        public string CreateUser(TenantUser tenant)
        {
            var tenantNode = TenantHelper.GetCurrentTenantHome(ConnectorContext.ContentService, tenant.TenantUId.ToString());
            var group      = userGroupService.GetUserGroup(tenant.Group);

            userGroupService.CreateUser(tenant);
            return(tenant.AssignedUmbracoUserId.ToString());
        }
        public string EditTenant(Tenant tenant)
        {
            var tenantNode = TenantHelper.GetCurrentTenantHome(contentService, tenant.TenantUId.ToString());

            if (tenantNode == null)
            {
                throw new TenantException(ExceptionCode.TenantNotFound.CodeToString(), ExceptionCode.TenantNotFound, tenant.TenantUId);
            }

            try
            {
                // Set values for node
                tenantNode.Name = tenant.Name;
                tenantNode.SetCultureName(tenant.Name, tenant.Languages.Default);
                List <String> lstcultures = new List <string>();
                foreach (var culture in tenantNode.AvailableCultures)
                {
                    lstcultures.Add(culture);//need this to not throw exception list modified
                }

                foreach (var culture in lstcultures)
                {
                    tenantNode.SetCultureName(tenant.Name, culture);
                }
                //tenantNode.Name = tenant.BrandName;
                //tenantNode.SetCultureName(tenant.BrandName, tenant.Languages.Default);
                tenantNode.SetValue("brandName", tenant.BrandName);
                tenantNode.SetValue("tenantUid", tenant.TenantUId);
                tenantNode.SetValue("domain", tenant.Domain);
                tenantNode.SetValue("subDomain", tenant.SubDomain);
                if (!string.IsNullOrEmpty(tenant.ApiKey))
                {
                    tenantNode.SetValue("apiKey", tenant.ApiKey);
                }
                if (!string.IsNullOrEmpty(tenant.AppId))
                {
                    tenantNode.SetValue("appId", tenant.AppId);
                }
                tenantNode.SetValue("defaultLanguage", tenant.Languages.Default);
                tenantNode.SetValue("tenantCurrencies", string.Join(",", tenant.Currencies.Codes));
                tenantNode.SetValue("tenantStatus", ENABLED);
                tenantNode.SetValue("languages", string.Join(", ", tenant.Languages.Alternate.ToList()));
                tenantNode.SetValue("tenantPreferencesProperty", JsonConvert.SerializeObject(tenant.TenantPreferences));

                contentService.Save(tenantNode);
                ConnectorContext.AuditService.Add(AuditType.Save, -1, tenantNode.Id, "Content Node", $"ContentNode for {tenant.TenantUId} has been edited");

                return(tenant.TenantUId.ToString());
            }
            catch (Exception ex)
            {
                logger.Error(typeof(HomeContentNode), ex.Message);
                logger.Error(typeof(HomeContentNode), ex.StackTrace);
                throw;
            }
        }
        public bool RefreshTenant(string tenantUid, string tenantName, string languageCode = "en")
        {
            int betHistoryId = -1, sportId = -1, casinoId = -1, pokerId = -1, inPlayId = -1, liveCasinoId = -1, vegasId = -1, lotteryId = -1, liveScheduleId = -1;

            var extended   = GetExtendedTenant(tenantUid);
            var children   = TenantHelper.GetTenantNodes(ConnectorContext.ContentService, tenantUid);
            var tenantNode = TenantHelper.GetCurrentTenantHome(ConnectorContext.ContentService, tenantUid);

            if (tenantNode == null)
            {
                throw new TenantException(ExceptionCode.TenantNotFound.CodeToString(), ExceptionCode.TenantNotFound, tenantUid);
            }

            string cultureIsoCode = languageCode;

            try
            {
                if (languageService.HasLanguage(cultureIsoCode))
                {
                    if (children.Any())
                    {
                        betHistoryId = children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Betting History")) != null?children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Betting History")).Id : -1;

                        sportId = children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Sport")) != null?children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Sport")).Id : -1;

                        inPlayId = children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("In-Play")) != null?children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("In-Play")).Id : -1;

                        casinoId = children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Casino")) != null?children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Casino")).Id : -1;

                        liveCasinoId = children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Live Casino")) != null?children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Live Casino")).Id : -1;

                        vegasId = children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Vegas")) != null?children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Vegas")).Id : -1;

                        lotteryId = children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Lottery")) != null?children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Lottery")).Id : -1;

                        pokerId = children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Poker")) != null?children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Poker")).Id : -1;

                        liveScheduleId = children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Live Schedule")) != null?children.SingleOrDefault(x => x.GetCultureName(cultureIsoCode).Equals("Live Schedule")).Id : -1;

                        UpdateTenantPages(betHistoryId, sportId, casinoId, pokerId, inPlayId, liveCasinoId, vegasId, lotteryId, liveScheduleId);
                    }

                    nodeHelper.RefreshNodeName(tenantUid, tenantName);
                }
                ReassignCulturesAndHostnames(tenantUid);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public int RenameMediaHome(TenantData tenant, TenantUser tenantUser)
        {
            var home = TenantHelper.GetCurrentTenantHome(ConnectorContext.ContentService, tenant.TenantUId.ToString());

            if (home == null)
            {
                throw new TenantException(ExceptionCode.TenantNotFound.CodeToString(), ExceptionCode.TenantNotFound, tenant.TenantUId);
            }

            IMedia             mediaHome = null;
            IReadOnlyUserGroup group     = null;

            if (tenantUser != null)
            {
                var uService = ConnectorContext.UserService;
                var user     = uService.GetByUsername(tenantUser.Username);
                group     = user.Groups.ToList()[0];
                mediaHome = mediaService.GetById(group.StartMediaId.Value);
            }
            else
            {
                mediaHome = mediaService.GetByLevel(1).SingleOrDefault(x => x.Name.Contains(tenant.Name));
            }

            if (mediaHome == null)
            {
                string mediaId = group?.StartMediaId.Value.ToString() ?? tenant.Name;
                //string mediaId = group?.StartMediaId.Value.ToString() ?? tenant.BrandName;
                throw new TenantException(ExceptionCode.MediaNodeDoesNotExist.CodeToString(), ExceptionCode.MediaNodeDoesNotExist, tenant.TenantUId, mediaId);
            }

            try
            {
                if (!mediaHome.Name.Equals(tenant.Name))
                {
                    mediaHome.Name = tenant.Name;
                    //mediaHome.Name = tenant.BrandName;
                    mediaService.Save(mediaHome);
                    ConnectorContext.AuditService.Add(AuditType.Save, -1, mediaHome.Id, "Media Folder", $"Media home for {tenant.TenantUId} has been renamed");
                }

                return(mediaHome.Id);
            }
            catch (System.Exception ex)
            {
                logger.Error(typeof(HomeMediaNode), ex.Message);
                logger.Error(typeof(HomeMediaNode), ex.StackTrace);
                throw;
            }
        }
Example #6
0
        public int CreateResetPasswordPage(Tenant tenant)
        {
            var home    = TenantHelper.GetCurrentTenantHome(contentService, tenant.TenantUId.ToString());
            var docType = contentTypeService.Get(_07_ResetPasswordViaEmailDocumentType.DOCUMENT_TYPE_ALIAS);

            try
            {
                var nodeName = "Reset Password";

                IContent resetPasswordNode = contentService.Create(nodeName, home.Id, _07_ResetPasswordViaEmailDocumentType.DOCUMENT_TYPE_ALIAS);
                resetPasswordNode.Name = nodeName;
                resetPasswordNode.SetCultureName(nodeName, tenant.Languages.Default);
                if (tenant.Languages.Default == "fa")
                {
                    resetPasswordNode.SetCultureName("بازیابی کلمه عبور", tenant.Languages.Default);
                }

                // Alternate Languages
                foreach (var language in tenant.Languages.Alternate)
                {
                    resetPasswordNode.SetCultureName($"{nodeName}-{language}", language.Trim());
                    if (language.Trim() == "fa")
                    {
                        resetPasswordNode.SetCultureName("بازیابی کلمه عبور", language.Trim());
                    }
                }

                contentService.Save(resetPasswordNode);

                ConnectorContext.AuditService.Add(AuditType.New, -1, resetPasswordNode.Id, "Content Node", $"ContentNode for {tenant.TenantUId.ToString()} has been created");
                return(resetPasswordNode.Id);
            }
            catch (Exception ex)
            {
                logger.Error(typeof(ResetPasswordContentNode), ex.Message);
                logger.Error(typeof(ResetPasswordContentNode), ex.StackTrace);
                throw;
            }
        }
        public int CreateConfirmEmail(Tenant tenant)
        {
            var home    = TenantHelper.GetCurrentTenantHome(contentService, tenant.TenantUId.ToString());
            var docType = contentTypeService.Get(_03_ConfirmEmailDocumentType.DOCUMENT_TYPE_ALIAS);

            try
            {
                var nodeName = "Confirm Email";

                IContent confirmEmailNode = contentService.Create(nodeName, home.Id, _03_ConfirmEmailDocumentType.DOCUMENT_TYPE_ALIAS);
                confirmEmailNode.Name = nodeName;
                confirmEmailNode.SetCultureName(nodeName, tenant.Languages.Default);
                if (tenant.Languages.Default == "fa")
                {
                    confirmEmailNode.SetCultureName("ایمیل تایید", tenant.Languages.Default);
                }
                // Alternate Languages
                foreach (var language in tenant.Languages.Alternate)
                {
                    confirmEmailNode.SetCultureName($"{nodeName}-{language}", language.Trim());
                    if (language.Trim() == "fa")
                    {
                        confirmEmailNode.SetCultureName("ایمیل تایید", language.Trim());
                    }
                }

                contentService.Save(confirmEmailNode);

                ConnectorContext.AuditService.Add(AuditType.New, -1, confirmEmailNode.Id, "Content Node", $"ContentNode for {tenant.TenantUId.ToString()} has been created");
                return(confirmEmailNode.Id);
            }
            catch (Exception ex)
            {
                logger.Error(typeof(ConfirmEmailContentNode), ex.Message);
                logger.Error(typeof(ConfirmEmailContentNode), ex.StackTrace);
                throw;
            }
        }
Example #8
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);
        }