예제 #1
0
        protected override void OnSubmit()
        {
            var isNew = _module == null;

            if (isNew)
            {
                _module     = new ModulePromo();
                _pageModule = new PageModule();
                _pageModule.ModuleTypeId = ModuleService.ModuleTypes[ModuleService.MODULE_PROMO];
                _pageModule.PageId       = _page.Id;
                _pageModule.Position     = _page.PageModules.Count + 1;
                Position = _pageModule.Position;
            }

            _module.Image                     = Image;
            _module.Text                      = Text;
            _module.ButtonText                = ButtonText;
            _module.ButtonLink                = !string.IsNullOrEmpty(ButtonText) ? ButtonLink : string.Empty;
            _module.ImageRight                = ImageRight;
            _module.TitleTop                  = TitleTop;
            _pageModule.Title                 = Title;
            _pageModule.BlueTitle             = BlueTitle;
            _pageModule.Theme                 = Theme;
            _pageModule.TransparentBackground = TransparentBackground;
            _pageModule.LootBox               = LootBox;
            _pageModule.LootBoxTop            = LootBoxTop;
            _pageModule.LootBoxLeft           = LootBoxLeft;
            _pageModule.State                 = State;

            using (var conn = new NTGDBTransactional())
            {
                _module.Save(conn);
                _pageModule.ModuleId = _module.Id;
                _pageModule.Save(conn);

                NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                        SessionVariables.User,
                                        (isNew ? "Created" : "Editted") + " Module",
                                        _page.Id,
                                        _page.Name,
                                        _module.Id,
                                        ModuleService.MODULE_PROMO,
                                        conn);

                conn.Commit();
                Id           = _module.Id;
                PageModuleId = _pageModule.Id;
                ModuleService.RefreshCacheModule(_pageModule.Id);
                AddMessage(Message.GLOBAL, new Message("Module saved", MessageTypes.Success));
            }
        }
        protected override void OnSubmit()
        {
            using (var conn = new NTGDBTransactional())
            {
                var claim = new LootBoxClaim();
                claim.Email     = Email;
                claim.FirstName = FirstName;
                claim.LastName  = LastName;
                claim.Date      = DateTime.UtcNow;
                claim.Save(conn);

                _pageModule.LootBox = false;
                _pageModule.Save(conn);
                conn.Commit();

                AddMessage(Message.GLOBAL, new Message("Congratulations!!! You have claimed this loot box!", MessageTypes.Success));
            }
        }
예제 #3
0
        protected override void OnSubmit()
        {
            var admin = new Admin()
            {
                Email     = Email,
                FirstName = FirstName,
                LastName  = LastName,
                Password  = EncryptionService.Encrypt(Password),
                RoleId    = _role.Id,
                Active    = true
            };

            using (var conn = new NTGDBTransactional())
            {
                admin.Save(conn);
                NTGLogger.LogSecurityAction(HttpContext.Current.Request, _sessionUser, "Created user " + admin.Id + " '" + admin.Email + "' with role " + _role.Name, conn);
                conn.Commit();
            }

            AddMessage(Message.GLOBAL, new Message("User successfully created", MessageTypes.Success));
        }
예제 #4
0
        protected override void OnSubmit()
        {
            var isNew = _page == null;

            if (isNew)
            {
                _page = new Page();
                _page.UploadFolder = Path.GetRandomFileName();
                _page.Position     = Page.Query.Count() + 1;
            }

            using (var conn = new NTGDBTransactional())
            {
                if (_page.Id == 0 || !_page.Name.Equals(Name))
                {
                    RedirectTo = Name.Replace(" ", "-").ToLower();
                }

                _page.Name            = Name;
                _page.HeroImage       = HeroImage;
                _page.MobileHeroImage = !string.IsNullOrEmpty(HeroImage) ? MobileHeroImage : null;

                /*The page with position 1 is the equivalent of home and should always have
                 * InMenu and as false because it has its own logic to appear in the top menu as the home link*/
                _page.InMenu       = _page.Position == 1 ? false : InMenu;
                _page.InBottomMenu = _page.Position == 1 ? false : InBottomMenu;
                //The home page cannot be inactive
                _page.Visible = _page.Position == 1 ? true : Visible;

                if (AdminLocked.HasValue)
                {
                    _page.AdminLocked = AdminLocked.Value;
                    if (!isNew)
                    {
                        NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                                SessionVariables.User,
                                                "Changed admin lock on page",
                                                _page.Id,
                                                _page.Name,
                                                null,
                                                null,
                                                conn);
                    }
                }

                _page.Save(conn);

                foreach (var module in _page.PageModules.OrderBy(pm => ModuleActions.OrderBy(ma => ma.Position).Select(ma => ma.Id).ToList().IndexOf(pm.Id)))
                {
                    var action = ModuleActions.SingleOrDefault(ma => ma.Id == module.Id);
                    if (action != null)
                    {
                        if (action.Delete)
                        {
                            ModuleService.DeleteModule(module, conn);
                            foreach (var nextAction in ModuleActions.Where(ma => ma.Position > action.Position))
                            {
                                nextAction.Position -= 1;
                            }
                            NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                                    SessionVariables.User,
                                                    "Deleted Module",
                                                    _page.Id,
                                                    _page.Name,
                                                    module.ModuleId,
                                                    ModuleType.Query.FirstOrDefault(mt => mt.Id == module.ModuleTypeId)?.Name,
                                                    conn);
                        }
                        else if (module.Position != action.Position)
                        {
                            module.Position = action.Position;
                            module.Save(conn);
                        }
                    }
                }

                NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                        SessionVariables.User,
                                        (isNew ? "Created" : "Editted") + " Page",
                                        _page.Id,
                                        _page.Name,
                                        null,
                                        null,
                                        conn);

                conn.Commit();
                ModuleService.RefreshModulesCache(_page.Id);
                AddMessage(Message.GLOBAL, new Message("Page " + Name + " successfully saved", MessageTypes.Success));
            }
        }
예제 #5
0
        protected override void OnSubmit()
        {
            _siteSettings = Global.GlobalVariables.SiteSettings;

            #region Layout

            _siteSettings.HeaderHomeImageUrl      = HeaderHomeImageUrl;
            _siteSettings.FooterHomeImageUrlLight = FooterHomeImageUrlLight;
            _siteSettings.FooterHomeImageUrlDark  = FooterHomeImageUrlDark;
            _siteSettings.LoadingImageUrl         = LoadingImageUrl;
            _siteSettings.BlogUrl     = BlogUrl;
            _siteSettings.ForumUrl    = ForumUrl;
            _siteSettings.ShopUrl     = ShopUrl;
            _siteSettings.FacebookUrl = FacebookUrl;
            _siteSettings.TwitterUrl  = TwitterUrl;
            _siteSettings.RedditUrl   = RedditUrl;
            _siteSettings.YouTubeUrl  = YouTubeUrl;
            _siteSettings.TwitchUrl   = TwitchUrl;

            #endregion

            #region Loot Box

            _siteSettings.LootBoxImageUrl   = LootBoxImageUrl;
            _siteSettings.LootBoxPopupTitle = LootBoxPopupTitle;
            _siteSettings.LootBoxPopupText  = LootBoxPopupText;

            #endregion

            #region Meta Tags

            _siteSettings.MetaFaviconImageUrl = MetaFaviconImageUrl;
            _siteSettings.MetaSiteTitle       = MetaSiteTitle;
            _siteSettings.MetaSiteDescription = MetaSiteDescription;

            #endregion

            #region Open Graph Tags

            _siteSettings.MetaOgImageUrl    = MetaOgImageUrl;
            _siteSettings.MetaOgImageType   = MetaOgImageType;
            _siteSettings.MetaOgImageWidth  = MetaOgImageWidth;
            _siteSettings.MetaOgImageHeight = MetaOgImageHeight;
            _siteSettings.MetaOgUrl         = MetaOgUrl;
            _siteSettings.MetaOgSiteName    = MetaOgSiteName;
            _siteSettings.MetaOgTitle       = MetaOgTitle;
            _siteSettings.MetaOgDescription = MetaOgDescription;
            _siteSettings.MetaOgType        = MetaOgType;
            _siteSettings.MetaOgLocale      = MetaOgLocale;

            #endregion

            #region Twitter Tags

            _siteSettings.MetaTwitterImageUrl    = MetaTwitterImageUrl;
            _siteSettings.MetaTwitterCard        = MetaTwitterCard;
            _siteSettings.MetaTwitterSite        = MetaTwitterSite;
            _siteSettings.MetaTwitterTitle       = MetaTwitterTitle;
            _siteSettings.MetaTwitterDescription = MetaTwitterDescription;

            #endregion

            #region Error Pages

            _siteSettings.ErrorImageIconTopUrl = ErrorImageIconTopUrl;
            _siteSettings.ErrorImage401Url     = ErrorImage401Url;
            _siteSettings.ErrorImage403Url     = ErrorImage403Url;
            _siteSettings.ErrorImage404Url     = ErrorImage404Url;
            _siteSettings.ErrorImage500Url     = ErrorImage500Url;
            _siteSettings.ErrorImage503Url     = ErrorImage503Url;

            #endregion

            using (var conn = new NTGDBTransactional())
            {
                NTGLogger.LogSiteAction(HttpContext.Current.Request, SessionVariables.User, "Editted Site Settings", null, null, null, null, conn);

                _siteSettings.Save(conn);
                conn.Commit();
            }

            AddMessage(Message.GLOBAL, new Message("Changes successfully saved", MessageTypes.Success));
        }
예제 #6
0
        protected override void OnSubmit()
        {
            var deleteLog = string.Empty;
            var orderLog  = string.Empty;

            using (var conn = new NTGDBTransactional())
            {
                foreach (var page in _pages.OrderBy(p => PageActions.OrderBy(pa => pa.Position).Select(pa => pa.Id).ToList().IndexOf(p.Id)))
                {
                    var action = PageActions.SingleOrDefault(pa => pa.Id == page.Id);
                    if (action != null)
                    {
                        if (action.Delete)
                        {
                            var pageModules = PageModule.Query.Where(pm => pm.PageId == page.Id);
                            foreach (var pageModule in pageModules)
                            {
                                ModuleService.DeleteModule(pageModule, conn);
                            }

                            var cloudinaryResult = CloudinaryService.DeleteFolder(page.UploadFolder);
                            if (!string.IsNullOrEmpty(cloudinaryResult.error))
                            {
                                NTGLogger.LogError(HttpContext.Current.Request, "Cloudinary Error", cloudinaryResult.error, nameof(PageListFormModel), nameof(CloudinaryService.DeleteFolder), conn);
                            }
                            page.Delete(conn);
                            deleteLog += " - " + action.Id;
                            foreach (var nextAction in PageActions.Where(pa => pa.Position > action.Position))
                            {
                                nextAction.Position -= 1;
                            }
                        }
                        else if (page.Position != action.Position)
                        {
                            page.Position = action.Position;
                            page.Save(conn);
                            orderLog += " - " + action.Id;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(orderLog))
                {
                    NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                            SessionVariables.User,
                                            "Changed pages order " + orderLog,
                                            null,
                                            null,
                                            null,
                                            null,
                                            conn);
                }

                if (!string.IsNullOrEmpty(deleteLog))
                {
                    NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                            SessionVariables.User,
                                            "Deleted pages " + deleteLog,
                                            null,
                                            null,
                                            null,
                                            null,
                                            conn);
                }

                conn.Commit();
                AddMessage(Message.GLOBAL, new Message("Pages successfully saved", MessageTypes.Success));
            }
        }
        protected override void OnSubmit()
        {
            var isNew = _module == null;

            if (isNew)
            {
                _module     = new ModuleGallery();
                _pageModule = new PageModule();
                _pageModule.ModuleTypeId = ModuleService.ModuleTypes[ModuleService.MODULE_GALLERY];
                _pageModule.PageId       = _page.Id;
                _pageModule.Position     = _page.PageModules.Count + 1;
                Position = _pageModule.Position;
            }

            _pageModule.Title                 = Title;
            _pageModule.BlueTitle             = BlueTitle;
            _pageModule.Theme                 = Theme;
            _pageModule.TransparentBackground = TransparentBackground;
            _pageModule.LootBox               = LootBox;
            _pageModule.LootBoxTop            = LootBoxTop;
            _pageModule.LootBoxLeft           = LootBoxLeft;
            _pageModule.State                 = State;

            using (var conn = new NTGDBTransactional())
            {
                _module.Save(conn);
                var subFormSuccess    = true;
                var subForm           = new CreateEditModuleGalleryImageSubFormModel();
                var positionReduction = 0;
                foreach (var image in Images.OrderBy(i => i.Position))
                {
                    if (image.IsDelete)
                    {
                        positionReduction++;
                    }
                    else if (positionReduction > 0)
                    {
                        image.IsModified = true;
                        image.Position  -= positionReduction;
                    }

                    if (image.IsModified || image.IsDelete)
                    {
                        subForm.Id            = image.Id;
                        subForm.Image         = image.Image;
                        subForm.Position      = image.Position;
                        subForm.ModuleGallery = _module;
                        subForm.IsDelete      = image.IsDelete;
                        subForm.IsNewModule   = Id == 0;
                        subForm.Links         = image.ModuleGalleryImageLinks.ToList();
                        subForm.Submit(conn, Messages);

                        subFormSuccess                = subFormSuccess && subForm.Success;
                        image.Id                      = subForm.Id;
                        image.ModuleGalleryId         = subForm.ModuleGallery.Id;
                        image.ModuleGalleryImageLinks = subForm.Links;
                        image.IsModified              = false;
                    }
                }

                if (subFormSuccess)
                {
                    _pageModule.ModuleId = _module.Id;
                    _pageModule.Save(conn);

                    NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                            SessionVariables.User,
                                            (isNew ? "Created" : "Editted") + " Module",
                                            _page.Id,
                                            _page.Name,
                                            _module.Id,
                                            ModuleService.MODULE_GALLERY,
                                            conn);

                    conn.Commit();
                    Id           = _module.Id;
                    PageModuleId = _pageModule.Id;
                    Images.RemoveAll(c => c.IsDelete);
                    ModuleService.RefreshCacheModule(_pageModule.Id);
                    AddMessage(Message.GLOBAL, new Message("Module saved", MessageTypes.Success));
                }
            }
        }
        protected override void OnSubmit()
        {
            var isNew = _module == null;

            if (isNew)
            {
                _module     = new ModuleProfileCards();
                _pageModule = new PageModule();
                _pageModule.ModuleTypeId = ModuleService.ModuleTypes[ModuleService.MODULE_PROFILE_CARDS];
                _pageModule.PageId       = _page.Id;
                _pageModule.Position     = _page.PageModules.Count + 1;
                Position = _pageModule.Position;
            }

            _pageModule.Title                 = Title;
            _pageModule.BlueTitle             = BlueTitle;
            _pageModule.Theme                 = Theme;
            _pageModule.TransparentBackground = TransparentBackground;
            _pageModule.LootBox               = LootBox;
            _pageModule.LootBoxTop            = LootBoxTop;
            _pageModule.LootBoxLeft           = LootBoxLeft;
            _pageModule.State                 = State;

            using (var conn = new NTGDBTransactional())
            {
                _module.Save(conn);
                var subFormSuccess    = true;
                var subForm           = new CreateEditModuleProfileCardsCardSubFormModel();
                var positionReduction = 0;
                foreach (var card in Cards.OrderBy(c => c.Position))
                {
                    if (card.IsDelete)
                    {
                        positionReduction++;
                    }
                    else if (positionReduction > 0)
                    {
                        card.IsModified = true;
                        card.Position  -= positionReduction;
                    }

                    if (card.IsModified || card.IsDelete)
                    {
                        subForm.Id                 = card.Id;
                        subForm.Name               = card.Name;
                        subForm.FacebookUrl        = card.FacebookUrl;
                        subForm.TwitterUrl         = card.TwitterUrl;
                        subForm.TwitchUrl          = card.TwitchUrl;
                        subForm.InstagramUrl       = card.InstagramUrl;
                        subForm.YouTubeUrl         = card.YouTubeUrl;
                        subForm.Image              = card.Image;
                        subForm.Position           = card.Position;
                        subForm.ModuleProfileCards = _module;
                        subForm.IsNewModule        = Id == 0;
                        subForm.IsDelete           = card.IsDelete;
                        subForm.Links              = card.ModuleProfileCardsCardLinks.ToList();
                        subForm.Submit(conn, Messages);

                        subFormSuccess                   = subFormSuccess && subForm.Success;
                        card.Id                          = subForm.Id;
                        card.ModuleProfileCardsId        = subForm.ModuleProfileCards.Id;
                        card.ModuleProfileCardsCardLinks = subForm.Links;
                        card.IsModified                  = false;
                    }
                }

                if (subFormSuccess)
                {
                    _pageModule.ModuleId = _module.Id;
                    _pageModule.Save(conn);

                    NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                            SessionVariables.User,
                                            (isNew ? "Created" : "Editted") + " Module",
                                            _page.Id,
                                            _page.Name,
                                            _module.Id,
                                            ModuleService.MODULE_PROFILE_CARDS,
                                            conn);

                    conn.Commit();
                    Id           = _module.Id;
                    PageModuleId = _pageModule.Id;
                    Cards.RemoveAll(c => c.IsDelete);
                    ModuleService.RefreshCacheModule(_pageModule.Id);
                    AddMessage(Message.GLOBAL, new Message("Module saved", MessageTypes.Success));
                }
            }
        }
        protected override void OnSubmit()
        {
            var isNew = _module == null;

            if (isNew)
            {
                _module     = new ModuleBoxes();
                _pageModule = new PageModule();
                _pageModule.ModuleTypeId = ModuleService.ModuleTypes[ModuleService.MODULE_BOXES];
                _pageModule.PageId       = _page.Id;
                _pageModule.Position     = _page.PageModules.Count + 1;
                Position = _pageModule.Position;
            }

            _module.Text                      = Text;
            _pageModule.Title                 = Title;
            _pageModule.BlueTitle             = BlueTitle;
            _pageModule.Theme                 = Theme;
            _pageModule.TransparentBackground = TransparentBackground;
            _pageModule.LootBox               = LootBox;
            _pageModule.LootBoxLeft           = LootBoxLeft;
            _pageModule.LootBoxTop            = LootBoxTop;
            _pageModule.State                 = State;

            using (var conn = new NTGDBTransactional())
            {
                _module.Save(conn);

                var subFormSuccess    = true;
                var subForm           = new CreateEditModuleBoxesBoxSubFormModel();
                var positionReduction = 0;
                foreach (var box in Boxes.OrderBy(b => b.Position))
                {
                    if (box.IsDelete)
                    {
                        positionReduction++;
                    }
                    else if (positionReduction > 0)
                    {
                        box.IsModified = true;
                        box.Position  -= positionReduction;
                    }

                    if (box.IsModified || box.IsDelete)
                    {
                        subForm.Id          = box.Id;
                        subForm.Title       = box.Title;
                        subForm.Icon        = box.Icon;
                        subForm.Color       = box.Color;
                        subForm.Text        = box.Text;
                        subForm.Url         = box.Url;
                        subForm.Position    = box.Position;
                        subForm.ModuleBoxes = _module;
                        subForm.IsDelete    = box.IsDelete;
                        subForm.IsNewModule = Id == 0;
                        subForm.Submit(conn, Messages);

                        subFormSuccess    = subFormSuccess && subForm.Success;
                        box.Id            = subForm.Id;
                        box.ModuleBoxesId = subForm.ModuleBoxes.Id;
                        box.IsModified    = false;
                    }
                }

                if (subFormSuccess)
                {
                    _pageModule.ModuleId = _module.Id;
                    _pageModule.Save(conn);

                    NTGLogger.LogSiteAction(HttpContext.Current.Request,
                                            SessionVariables.User,
                                            (isNew ? "Created" : "Editted") + " Module",
                                            _page.Id,
                                            _page.Name,
                                            _module.Id,
                                            ModuleService.MODULE_BOXES,
                                            conn);
                    conn.Commit();

                    Id           = _module.Id;
                    PageModuleId = _pageModule.Id;
                    Boxes.RemoveAll(b => b.IsDelete);
                    ModuleService.RefreshCacheModule(_pageModule.Id);
                    AddMessage(Message.GLOBAL, new Message("Module saved", MessageTypes.Success));
                }
            }
        }
예제 #10
0
        protected override void OnSubmit()
        {
            string oldRole         = null;
            var    emailChanged    = !_admin.Email.Equals(Email);
            var    passwordChanged = !string.IsNullOrEmpty(Password);
            var    activeChanged   = Active.HasValue && _admin.Active != Active.Value;

            _admin.FirstName = FirstName;
            _admin.LastName  = LastName;

            using (var conn = new NTGDBTransactional())
            {
                NTGLogger.LogSecurityAction(HttpContext.Current.Request, _sessionUser, "Editted user " + _admin.Id + " '" + _admin.Email + "'", conn);

                if (activeChanged)
                {
                    _admin.Active = Active.Value;
                    NTGLogger.LogSecurityAction(HttpContext.Current.Request, _sessionUser, (_admin.Active ? "Reactivated" : "Deactivated") + " admin " + _admin.Id + " '" + _admin.Email + "'", conn);
                }

                if (emailChanged)
                {
                    NTGLogger.LogSecurityAction(HttpContext.Current.Request, _sessionUser, "Changed email of admin " + _admin.Id + " '" + _admin.Email + "': " + _admin.Email + " to " + Email);
                    _admin.Email = Email;
                }

                if (passwordChanged)
                {
                    NTGLogger.LogSecurityAction(HttpContext.Current.Request, _sessionUser, "Changed password of admin " + _admin.Id + " '" + _admin.Email + "'", conn);
                    var encryptedPassword = EncryptionService.Encrypt(Password);
                    _admin.Password = encryptedPassword;
                    Password        = string.Empty;
                    VerifyPassword  = string.Empty;
                }

                if (_role != null)
                {
                    NTGLogger.LogSecurityAction(HttpContext.Current.Request, _sessionUser, "Changed role of admin " + _admin.Id + " '" + _admin.Email + "': " + oldRole + " to " + _role.Name, conn);
                    oldRole       = _admin.Role.Name;
                    _admin.RoleId = _role.Id;
                }

                _admin.Save(conn);
                conn.Commit();
            }


            Relog = User == _sessionUser.Email && (emailChanged || passwordChanged || activeChanged);
            if (Relog)
            {
                FormsAuthentication.SignOut();
                if (activeChanged)
                {
                    AddMessage(Message.GLOBAL, new Message("User has been deactivated. Good Bye!", MessageTypes.Success));
                }
                else
                {
                    AddMessage(Message.GLOBAL, new Message("User access information changed. Please log in again", MessageTypes.Success));
                }
            }

            AddMessage(Message.GLOBAL, new Message("Changes successfully saved", MessageTypes.Success));
        }