private void ResolveDecays(AdministrationToolViewModel viewModel) { var cleanup = new List <Guid>(); foreach (var child in _contentLoader.Get <PageData>(ContentReference.StartPage).GetDescendants(2)) { if (child is ISearchConfigurableParent) { var decay = new Decay(child.ContentGuid); cleanup.Add(child.ContentGuid); _decayRepository.CreateIfNotExisting(decay, m => m.ContentGuid == decay.ContentGuid); } } foreach (var decay in _decayRepository.ReadAll()) { if (!cleanup.Contains(decay.ContentGuid)) { _decayRepository.Delete(decay); continue; } viewModel.Decays.Add(new AdministrationToolViewModel.DecayViewModel { Model = decay, Name = ResolveContentName(decay.ContentGuid), Breadcrumb = ResolveBreadcrumb(decay.ContentGuid) }); } }
private void ResolveBoosts(AdministrationToolViewModel viewModel) { var cleanup = new List <Guid>(); foreach (var child in _contentLoader.Get <PageData>(ContentReference.StartPage).GetDescendants(2)) { if (child is ISearchConfigurableParent) { var boost = new Boost(child.ContentGuid); cleanup.Add(child.ContentGuid); _boostRepository.CreateIfNotExisting(boost, i => i.ContentGuid == boost.ContentGuid); } } foreach (var boost in _boostRepository.ReadAll()) { if (!cleanup.Contains(boost.ContentGuid)) { _boostRepository.Delete(boost); continue; } viewModel.Boosts.Add(new AdministrationToolViewModel.BoostViewModel { Model = boost, Name = ResolveContentName(boost.ContentGuid), Breadcrumb = ResolveBreadcrumb(boost.ContentGuid) }); } }
private void ResolveAllContent(AdministrationToolViewModel viewModel) { foreach (var contentLink in ServiceLocator.Current.GetInstance <IContentLoader>().GetDescendents(ContentReference.StartPage).DistinctBy(c => c.ID)) { var localizedContent = ServiceLocator.Current.GetInstance <IContentLoader>() .Get <IContent>(contentLink) as ILocalizable; if (localizedContent != null) { foreach (var language in localizedContent.ExistingLanguages) { var lang = language.Name; var content = ServiceLocator.Current.GetInstance <IContentLoader>().Get <IContent>(contentLink, language); if (!viewModel.Content.ContainsKey(lang)) { viewModel.Content[lang] = new List <AdministrationToolViewModel.ContentViewModel>(); } viewModel.Content[lang].Add(new AdministrationToolViewModel.ContentViewModel { ContentGuid = content.ContentGuid, Name = content.Name, Language = lang }); } } } }
private void ResolveSynonymContainers(AdministrationToolViewModel viewModel) { foreach (var synonymContainer in _synonymContainerRepository.ReadAll()) { if (!viewModel.SynonymContainers.ContainsKey(synonymContainer.Language)) { viewModel.SynonymContainers[synonymContainer.Language] = new List <SynonymContainer>(); } viewModel.SynonymContainers[synonymContainer.Language].Add(synonymContainer); } }
private void ResolvePropertyWeights(AdministrationToolViewModel viewModel) { var previous = _weightSettingRepository.ReadAll(); var current = ServiceLocator.Current.GetInstance <ElasticEpiDocument>() .GetLanguageAnalyzableProperties().Select(p => p.ToElasticPropertyName()).ToList(); foreach (var propertyName in current) { _weightSettingRepository.CreateIfNotExisting(new WeightSetting(propertyName, 1), pw => pw.Property == propertyName); } if (previous.Count != current.Count) { foreach (var property in previous.Where(ws => !current.Contains(ws.Property))) { _weightSettingRepository.Delete(property); } } viewModel.PropertyWeightSettings = _weightSettingRepository.ReadAll(); }
private void ResolveBestBets(AdministrationToolViewModel viewModel) { foreach (var bestBet in _bestBetRepository.ReadAll()) { if (!viewModel.BestBets.ContainsKey(bestBet.Language)) { viewModel.BestBets[bestBet.Language] = new List <AdministrationToolViewModel.BestBetViewModel>(); } viewModel.BestBets[bestBet.Language].Add(new AdministrationToolViewModel.BestBetViewModel { Model = bestBet, Contents = bestBet.Contents.Select( i => new AdministrationToolViewModel.BestBetContentViewModel { Model = i, Name = ResolveContentName(i.ContentGuid, bestBet.Language) }).OrderByDescending(i => i.Model.Order).ToList() }); } }
private AdministrationToolViewModel ResolveViewModel() { var viewModel = new AdministrationToolViewModel(); foreach (var language in ServiceLocator.Current.GetInstance <ILanguageBranchRepository>().ListEnabled()) { viewModel.AvailableLanguages.Add(new AdministrationToolViewModel.LanguageViewModel { Name = language.Name, Code = language.LanguageID }); } ResolveBoosts(viewModel); ResolveDecays(viewModel); ResolveSynonymContainers(viewModel); ResolveBestBets(viewModel); ResolveAllContent(viewModel); ResolvePropertyWeights(viewModel); return(viewModel); }