public async Task EditHeightAsync(int pageSectionId, PageSectionHeight height) { var pageSection = await _context.PageSections.SingleOrDefaultAsync(x => x.PageSectionId == pageSectionId); if (pageSection == null) { return; } var document = new Document(pageSection.PageSectionBody); document.UpdateSectionHeight(string.Format("section-{0}", pageSectionId), height); pageSection.PageSectionBody = document.OuterHtml; await _context.SaveChangesAsync(); }
public void UpdateSectionHeight(string elementId, PageSectionHeight height) { var element = _document.GetElementbyId(elementId); var selectedHeight = string.Format("height-{0}", height).ToLower(); var heightClasses = new List <string> { "height-tall", "height-medium", "height-small", "height-tiny", "height-standard" }; var classAttribute = element.Attributes.SingleOrDefault(x => x.Name == "class"); foreach (var heightClass in heightClasses) { classAttribute.Value = classAttribute.Value.Replace(heightClass, selectedHeight); } }
public void Height(int pageSectionId, PageSectionHeight height) { var pageSection = _context.PageSections.SingleOrDefault(x => x.PageSectionId == pageSectionId); if (pageSection == null) { return; } var document = new Document(pageSection.PageSectionBody); document.UpdateSectionHeight(string.Format("section-{0}", pageSectionId), height); pageSection.PageSectionBody = document.OuterHtml; _context.SaveChanges(); }