Exemplo n.º 1
0
        public bool AddPage(Page page)
        {
            _unitOfWork.PageRepository.Add(page);

            try
            {
                _unitOfWork.Save();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds new entries into the localized phrases table for all phrases in the 'translation' dictionary.
 /// It also associates the page 'page' with the list of translated phrases
 /// </summary>
 /// <param name="page">Page object representing the page to translate</param>
 /// <param name="translations">Dictionary of translation terms [Phrase][TranslatedPhrase]</param>
 /// <param name="language">Language to translate to</param>
 private void TranslatePage(Page page, Dictionary<string, string> translations, string language = "EN")
 {
     // For all phrases inside 'translation', add a new translation entry by associating it
     // with the specified language.
     page.LocalizedTexts.ToList().ForEach(t =>
     {
         t.TranslatedText = TranslatedTextFromDictionaryOrDefault(t.TextKey, translations);
         t.LanguageCode = language;
     });
 }
Exemplo n.º 3
0
 public List<LocalizedText> GetLocalizedTextForPage(Page page, string language = "EN")
 {
     try
     {
         var phrases = LocalizedTextForPage(page.PageId, language);
         return phrases.ToList();
     }
     catch (Exception)
     {
         // TODO: Log error
         throw new ApplicationException(string.Format("Error fetching localized text for page: {0}", page.PageKey));
     }
 }
Exemplo n.º 4
0
 public bool UpdatePage(Page page)
 {
     _unitOfWork.PageRepository.Edit(page);
     try
     {
         _unitOfWork.Save();
         return true;
     }
     catch (Exception exception)
     {
         // TODO: Log error
         throw new ApplicationException(string.Format("Error updating page information"), exception);
     }
 }
Exemplo n.º 5
0
 public bool DeletePage(Page page)
 {
     // INFO: Remember to set cascade delete for Page and LocalizedText
     try
     {
         _unitOfWork.PageRepository.Delete(page);
         _unitOfWork.Save();
         return true;
     }
     catch (Exception exception)
     {
         // TODO: Log error here
         throw new ApplicationException("Error removing page information", exception);
     }
 }