public void LogModificationToText(Guid textId) { if (TextRepository.Exists(textId)) { Text textOfModdedDocument = TextRepository.GetById(textId); Content contentOfModdedDocument = textOfModdedDocument.ContentThatBelongs; if (HeaderRepository.ExistsWithContent(contentOfModdedDocument)) { Header headerOfModdedDocument = HeaderRepository.GetByContent(contentOfModdedDocument); LogModificationToDocument(headerOfModdedDocument.DocumentThatBelongs.Id); } else if (ParagraphRepository.ExistsWithContent(contentOfModdedDocument)) { Paragraph paragraphOfModdedDocument = ParagraphRepository.GetByContent(contentOfModdedDocument); LogModificationToDocument(paragraphOfModdedDocument.DocumentThatBelongs.Id); } else if (FooterRepository.ExistsWithContent(contentOfModdedDocument)) { Footer footerOfModdedDocument = FooterRepository.GetByContent(contentOfModdedDocument); LogModificationToDocument(footerOfModdedDocument.DocumentThatBelongs.Id); } } else { throw new MissingTextException("This text is not in the database."); } }