예제 #1
0
        public Text AddToHeader(Guid headerId, Text text)
        {
            if (HeaderRepository.Exists(headerId))
            {
                Header header = HeaderRepository.GetById(headerId);
                header.StyleClass = null;

                Header headerForText = header;

                Content contentOfHeader = headerForText.Content;

                IEnumerable <Text> headerTexts = TextRepository.GetByContent(contentOfHeader);

                if (headerTexts.Count() == 0)
                {
                    text.Id                 = Guid.NewGuid();
                    text.Position           = 0;
                    text.ContentThatBelongs = contentOfHeader;
                    TextRepository.Add(text);

                    return(text);
                }
                else
                {
                    throw new ExistingTextException("There is an existing text in the selected header.");
                }
            }
            else
            {
                throw new MissingHeaderException("This header does not exist in the database");
            }
        }
 public void Delete(Guid headerId)
 {
     if (HeaderRepository.Exists(headerId))
     {
         HeaderRepository.Delete(headerId);
     }
     else
     {
         throw new MissingHeaderException("This header is not in the database.");
     }
 }
 public void LogModificationToHeader(Guid headerId)
 {
     if (HeaderRepository.Exists(headerId))
     {
         Header headerOfModdedDocument = HeaderRepository.GetById(headerId);
         LogModificationToDocument(headerOfModdedDocument.DocumentThatBelongs.Id);
     }
     else
     {
         throw new MissingHeaderException("This header is not in the database.");
     }
 }
 public void Update(Guid headerId, Header newHeaderData)
 {
     if (HeaderRepository.Exists(headerId))
     {
         Header headerToUpdate = HeaderRepository.GetById(headerId);
         if (newHeaderData.StyleClass != null && !StyleClassRepository.Exists(newHeaderData.StyleClass.Name))
         {
             newHeaderData.StyleClass = null;
         }
         headerToUpdate.StyleClass = newHeaderData.StyleClass;
         HeaderRepository.Update(headerToUpdate);
     }
     else
     {
         throw new MissingHeaderException("The header is not in the database.");
     }
 }
예제 #5
0
 public Text GetByHeader(Guid headerId)
 {
     if (HeaderRepository.Exists(headerId))
     {
         Header             headerForText   = HeaderRepository.GetById(headerId);
         Content            contentOfHeader = headerForText.Content;
         IEnumerable <Text> headerTexts     = TextRepository.GetByContent(contentOfHeader);
         if (headerTexts.Count() != 0)
         {
             return(headerTexts.First());
         }
         else
         {
             throw new MissingTextException("This text is not in the database");
         }
     }
     else
     {
         throw new MissingHeaderException("This header does not exist in the database");
     }
 }