public async Task FilterAsync(ContentOptionsViewModel model, IQuery <ContentItem> query, IUpdateModel updater) { var viewModel = new LocalizationContentsAdminFilterViewModel(); if (await updater.TryUpdateModelAsync(viewModel, "Localization")) { // Show localization content items // This is intended to be used by adding ?Localization.ShowLocalizedContentTypes to an AdminMenu url. if (viewModel.ShowLocalizedContentTypes) { var localizedTypes = _contentDefinitionManager .ListTypeDefinitions() .Where(x => x.Parts.Any(p => p.PartDefinition.Name == nameof(LocalizationPart))) .Select(x => x.Name); query.With <ContentItemIndex>(x => x.ContentType.IsIn(localizedTypes)); } // Show contained elements for the specified culture else if (!String.IsNullOrEmpty(viewModel.SelectedCulture)) { query.With <LocalizedContentItemIndex>(i => (i.Published || i.Latest) && i.Culture == viewModel.SelectedCulture); } } }
public override async Task <IDisplayResult> UpdateAsync(ContentOptionsViewModel model, IUpdateModel updater) { var viewModel = new LocalizationContentsAdminFilterViewModel(); if (await updater.TryUpdateModelAsync(viewModel, "Localization")) { if (viewModel.ShowLocalizedContentTypes) { model.RouteValues.TryAdd("Localization.ShowLocalizedContentTypes", viewModel.ShowLocalizedContentTypes); } model.FilterResult.MapFrom(viewModel); } return(Edit(model, updater)); }
public override async Task <IDisplayResult> UpdateAsync(ContentOptionsViewModel model, IUpdateModel updater) { var viewModel = new LocalizationContentsAdminFilterViewModel(); if (await updater.TryUpdateModelAsync(viewModel, "Localization")) { if (viewModel.ShowLocalizedContentTypes) { model.RouteValues.TryAdd("Localization.ShowLocalizedContentTypes", viewModel.ShowLocalizedContentTypes); } if (!string.IsNullOrEmpty(viewModel.SelectedCulture)) { model.RouteValues.TryAdd("Localization.SelectedCulture", viewModel.SelectedCulture); } } return(Edit(model, updater)); }
public async Task FilterAsync(ContentOptionsViewModel model, IQuery <ContentItem> query, IUpdateModel updater) { var viewModel = new LocalizationContentsAdminFilterViewModel(); if (await updater.TryUpdateModelAsync(viewModel, "Localization")) { // Show localization content items // This is intended to be used by adding ?Localization.ShowLocalizedContentTypes to an AdminMenu url. if (viewModel.ShowLocalizedContentTypes) { var localizedTypes = _contentDefinitionManager .ListTypeDefinitions() .Where(x => x.Parts.Any(p => p.PartDefinition.Name == nameof(LocalizationPart))) .Select(x => x.Name); query.With <ContentItemIndex>(x => x.ContentType.IsIn(localizedTypes)); } } }