public LanguagesView() { InitializeComponent(); newLanguage = new Language(); myLangauagesViewSource = (CollectionViewSource)this.Resources["languageViewSource"]; DataContext = this; }
private void UpdateCommandHandler(object sender, ExecutedRoutedEventArgs e) { if (newLanguageGrid.IsVisible) { newLanguage = new Model.Language(); Model.Language nlanguage = myLangauagesViewSource.View.CurrentItem as Model.Language; if (nlanguage != null) { newLanguage.LanguageName = nlanguage?.LanguageName; if (!string.IsNullOrWhiteSpace(newLanguage?.LanguageName)) { myLangauagesViewSource.View.Refresh(); myLangauagesViewSource.View.MoveCurrentTo(newLanguage); context.SaveChanges(); Messenger.Default.Send <string>(Utils.LanguageAddedMessage); } else { MessageBox.Show("Language Is Empty."); } } newLanguageGrid.Visibility = Visibility.Collapsed; existinglanguageDataGrid.Visibility = Visibility.Visible; } }
public void LoadPageForMissedLanguage_PageLoadedWithDefaultLanguage() { var language = new Model.Language("es-ES"); var service = GetStaticContentService(); var result = service.LoadStoreStaticContent(new Model.Store { Id = "TestStore" }); var page = result.Where(x => x.Url.Equals("about_us") && (x.Language == language || x.Language.IsInvariant)).Single(); Assert.IsType<ContentPage>(page); Assert.NotEmpty(page.Content); Assert.Equal(page.Url, "about_us"); Assert.Equal(Path.GetFileName(page.StoragePath), "about_us.md"); }
public void LoadPageForLanguage_PageLoadedFromFolder() { var language = new Model.Language("en-US"); var service = GetStaticContentService(); var result = service.LoadStoreStaticContent(new Model.Store { Id = "TestStore" }); var page = result.Where(x=>x.Url.Equals("folder1/about_us") && x.Language == language).Single(); Assert.IsType<ContentPage>(page); Assert.Equal(page.Language, language); Assert.NotEmpty(page.Content); Assert.Equal(page.Url, "folder1/about_us"); Assert.Equal(Path.GetFileName(page.StoragePath), "about_us.en-US.md"); }
public void LoadPageForMissedLanguage_PageLoadedWithDefaultLanguage() { var language = new Model.Language("es-ES"); var service = GetStaticContentService(); var result = service.LoadContentItemsByUrl("/about_us", new Model.Store { Id = "TestStore" }, language, () => new ContentPage()); var page = result.Single(); Assert.IsType<ContentPage>(page); Assert.Equal(page.Language, language); Assert.NotEmpty(page.Content); Assert.Equal(page.Url, "about_us"); Assert.Equal(Path.GetFileName(page.LocalPath), "about_us.md"); }
public void LoadPageForMissedLanguage_PageLoadedWithDefaultLanguage() { var language = new Model.Language("es-ES"); var service = GetStaticContentService(); var result = service.LoadStoreStaticContent(new Model.Store { Id = "TestStore" }); var page = result.Where(x => x.Url.Equals("about_us") && (x.Language == language || x.Language.IsInvariant)).Single(); Assert.IsType <ContentPage>(page); Assert.NotEmpty(page.Content); Assert.Equal(page.Url, "about_us"); Assert.Equal(Path.GetFileName(page.LocalPath), "about_us.md"); }
public void StaticContent_get_formatted_permalink() { var language = new Model.Language("en-US"); var service = GetStaticContentService(); var result = service.LoadStoreStaticContent(new Model.Store { Id = "TestStore" }); var page = result.Where(x => x.Url.Equals("blogs/news/about_us_permalink") && (x.Language == language || x.Language.IsInvariant)).Single(); Assert.IsType<ContentPage>(page); Assert.NotEmpty(page.Content); Assert.Equal(page.Url, "blogs/news/about_us_permalink"); Assert.Equal(Path.GetFileName(page.StoragePath), "about_us_permalink.md"); }
public void LoadPageForLanguage_PageLoadedFromFolder() { var language = new Model.Language("en-US"); var service = GetStaticContentService(); var result = service.LoadStoreStaticContent(new Model.Store { Id = "TestStore" }); var page = result.Where(x => x.Url.Equals("folder1/about_us") && x.Language == language).Single(); Assert.IsType <ContentPage>(page); Assert.Equal(page.Language, language); Assert.NotEmpty(page.Content); Assert.Equal(page.Url, "folder1/about_us"); Assert.Equal(Path.GetFileName(page.LocalPath), "about_us.en-US.md"); }
public void StaticContent_get_formatted_permalink() { var language = new Model.Language("en-US"); var service = GetStaticContentService(); var result = service.LoadStoreStaticContent(new Store { Id = "TestStore" }); var page = result.Single(x => x.Url.Equals("blogs/news/about_us_permalink") && (x.Language == language || x.Language.IsInvariant)); Assert.IsType <ContentPage>(page); Assert.NotEmpty(page.Content); Assert.Equal(page.Url, "blogs/news/about_us_permalink"); Assert.Equal(Path.GetFileName(page.StoragePath), "about_us_permalink.md"); }
public void LoadPageForMissedLanguage_PageLoadedWithDefaultLanguage() { var language = new Model.Language("es-ES"); var service = GetStaticContentService(); var result = service.LoadContentItemsByUrl("/about_us", new Model.Store { Id = "TestStore" }, language, () => new ContentPage()); var page = result.Single(); Assert.IsType <ContentPage>(page); Assert.Equal(page.Language, language); Assert.NotEmpty(page.Content); Assert.Equal(page.Url, "about_us"); Assert.Equal(Path.GetFileName(page.LocalPath), "about_us.md"); }
public void StaticContent_get_blogs() { var language = new Model.Language("en-US"); var service = GetStaticContentService(); var result = service.LoadStoreStaticContent(new Model.Store { Id = "TestStore" }); var blog = result.OfType<Blog>().FirstOrDefault(x => x.Name == "news"); var page = result.Where(x => x.Url.Equals("blogs/news/post1") && (x.Language == language || x.Language.IsInvariant)).Single(); Assert.NotNull(blog); Assert.IsType<BlogArticle>(page); Assert.NotEmpty(page.Content); Assert.Equal(page.Url, "blogs/news/post1"); Assert.Equal(((BlogArticle)page).BlogName, "news"); }
public void StaticContent_get_blogs() { var language = new Model.Language("en-US"); var service = GetStaticContentService(); var result = service.LoadStoreStaticContent(new Model.Store { Id = "TestStore" }); var blog = result.OfType <Blog>().FirstOrDefault(x => x.Name == "news"); var page = result.Where(x => x.Url.Equals("blogs/news/post1") && (x.Language == language || x.Language.IsInvariant)).Single(); Assert.NotNull(blog); Assert.IsType <BlogArticle>(page); Assert.NotEmpty(page.Content); Assert.Equal(page.Url, "blogs/news/post1"); Assert.Equal(((BlogArticle)page).BlogName, "news"); }
public static ApiContract.v1.Language ToContract(this Model.Language source) => new ApiContract.v1.Language { Key = source.Key, Name = source.Name };