public Footer GetByDocument(Guid documentId) { if (DocumentRepository.Exists(documentId)) { if (FooterRepository.ExistsForDocument(documentId)) { return(FooterRepository.GetByDocument(documentId)); } else { throw new MissingFooterException("This footer is not in the database"); } } else { throw new MissingDocumentException("This document is not on the database."); } }
public Footer Add(Guid documentId, Footer footer) { if (DocumentRepository.Exists(documentId)) { if (!FooterRepository.ExistsForDocument(documentId)) { Document documentThatBelongs = DocumentRepository.GetById(documentId); documentThatBelongs.StyleClass = null; footer.DocumentThatBelongs = documentThatBelongs; footer.Id = Guid.NewGuid(); footer.Content = new Content() { Id = Guid.NewGuid() }; if (footer.StyleClass != null && !StyleClassRepository.Exists(footer.StyleClass.Name)) { footer.StyleClass = null; } ContentRepository.Add(footer.Content); FooterRepository.Add(footer); return(footer); } else { throw new ExistingFooterException("This document already has a footer."); } } else { throw new MissingDocumentException("This document is not in the database."); } }
private string ApplyDocumentStyle(Document document, Format format) { IEnumerable <Style> currentStyles = GetStylesWithInheritance(document.StyleClass, format); string appliedHtmlCode = ""; if (!HeaderRepository.ExistsForDocument(document.Id) && !FooterRepository.ExistsForDocument(document.Id)) { appliedHtmlCode = "" + ApplyParagraphStyles(ParagraphRepository.GetAllByDocument(document.Id), format, currentStyles); } else if (!FooterRepository.ExistsForDocument(document.Id)) { appliedHtmlCode = "" + ApplyHeaderStyle(HeaderRepository.GetByDocument(document.Id), format, currentStyles) + "<br>" + ApplyParagraphStyles(ParagraphRepository.GetAllByDocument(document.Id), format, currentStyles); } else { appliedHtmlCode = "" + ApplyHeaderStyle(HeaderRepository.GetByDocument(document.Id), format, currentStyles) + "<br>" + ApplyParagraphStyles(ParagraphRepository.GetAllByDocument(document.Id), format, currentStyles) + "<br>" + ApplyFooterStyles(FooterRepository.GetByDocument(document.Id), format, currentStyles); } return(appliedHtmlCode); }