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));
                }
            }
        }