Beispiel #1
0
        public void BackgroundType(int pageSectionId, PageSectionBackgroundType backgroundType)
        {
            var pageSection = _context.PageSections.SingleOrDefault(x => x.PageSectionId == pageSectionId);

            if (pageSection == null)
            {
                return;
            }

            var document = new Document(pageSection.PageSectionBody);

            document.UpdateBackgroundType(string.Format("section-{0}", pageSectionId), backgroundType);

            pageSection.PageSectionBody = document.OuterHtml;

            _context.SaveChanges();
        }
        public void UpdateBackgroundType(string elementId, PageSectionBackgroundType backgroundType)
        {
            var element = _document.GetElementbyId(elementId);

            var selectedHeight = string.Format("background-{0}", backgroundType).ToLower();

            var heightClasses = new List <string> {
                "background-static", "background-parallax"
            };

            var classAttribute = element.Attributes.SingleOrDefault(x => x.Name == "class");

            foreach (var heightClass in heightClasses)
            {
                classAttribute.Value = classAttribute.Value.Replace(heightClass, selectedHeight);
            }
        }