public bool AddPage(Page page) { _unitOfWork.PageRepository.Add(page); try { _unitOfWork.Save(); return true; } catch (Exception) { return false; } }
/// <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; }); }
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)); } }
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); } }
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); } }