예제 #1
0
        private static void SaveHomepage(User user, Homepage homepage, IList <BinaryFile> imageList, bool publish)
        {
            ErrorList errors = ValidateHomepage(homepage, imageList);

            if (errors.Count > 0)
            {
                throw new InvalidHomepageException(errors, homepage);
            }

            homepage.IsPublished = publish;
            Homepage.Update(homepage);

            if (homepage.CategoriesLoaded)
            {
                HomepageCategory.DeleteHomepageCategories(homepage.HomepageId.GetValueOrDefault());

                foreach (HomepageCategory hc in homepage.HomepageCategoryList)
                {
                    hc.HomepageId = homepage.HomepageId.GetValueOrDefault();
                    HomepageCategory.Update(hc);
                }
            }

            SaveHomepageImages(homepage, imageList);

            if (publish)
            {
                AuditLogManager.LogUserAction(user, AuditUserAction.PublishHomepage, string.Format("Published Homepage: {0}", homepage.HomepageId));
            }
            else
            {
                AuditLogManager.LogUserAction(user, AuditUserAction.PreviewHomepage, string.Format("Preview Homepage created: {0}", homepage.HomepageId));
            }
        }
예제 #2
0
        private void GetHomepageAndImages(ref Homepage homepage, ref IList <BinaryFile> imageList)
        {
            // Set the brand ID for th brand being edited
            homepage.BrandId = EditingBrandId;

            // Add the metadata
            homepage.IntroText = IntroTextBox.Text ?? string.Empty;
            homepage.Url1      = HomepageImageEditor1.Url;
            homepage.Url2      = HomepageImageEditor2.Url;
            homepage.Url3      = HomepageImageEditor3.Url;
            homepage.Url4      = HomepageImageEditor4.Url;

            // Bumper page settings
            homepage.BumperPageSkip = SkipBumperPageCheckBox.Checked;
            homepage.BumperPageHtml = (IncludeBumperPageCheckBox.Checked) ? BumperPageTextBox.Text : string.Empty;

            // Custom HTML
            homepage.CustomHtml = CustomHtmlTextBox.Text ?? string.Empty;

            // Other settings
            homepage.HomepageTypeId       = HomepageTemplateTypeDropDownList.SelectedId;
            homepage.LastModifiedByUserId = CurrentUser.UserId.GetValueOrDefault();
            homepage.LastModifiedDate     = DateTime.Now;

            // Add image information
            imageList = new List <BinaryFile>
            {
                new BinaryFile(HomepageImageEditor1.ImageUpload.PostedFile),
                new BinaryFile(HomepageImageEditor2.ImageUpload.PostedFile),
                new BinaryFile(HomepageImageEditor3.ImageUpload.PostedFile),
                new BinaryFile(HomepageImageEditor4.ImageUpload.PostedFile)
            };

            // Clear old categories
            homepage.HomepageCategoryList.Clear();

            // Add selected categories
            for (int i = 0; i < SelectedCategoriesListBox.Items.Count; i++)
            {
                HomepageCategory hc = HomepageCategory.New();
                hc.CategoryId = Convert.ToInt32(SelectedCategoriesListBox.Items[i].Value);
                hc.OrderBy    = i;
                homepage.HomepageCategoryList.Add(hc);
            }
        }