protected override DriverResult Editor(GamePart part, IUpdateModel updater, dynamic shapeHelper) { var viewModel = new GamePartVM(); if (updater.TryUpdateModel(viewModel, Prefix, null, null)) { Mapper.Initialize(cfg => { cfg.CreateMap <GamePartVM, GamePart>() .ForMember(dest => dest.GameDate, opt => opt.Ignore()); }); Mapper.Map <GamePartVM, GamePart>(viewModel, part); if (!String.IsNullOrWhiteSpace(viewModel.GameDate)) { part.GameDate = _dateLocalization.StringToDatetime(viewModel.GameDate, "") ?? DateTime.Now; } } return(Editor(part, shapeHelper)); }
/// <summary> /// Converts the data from the form into a list of view models for the task schedulers /// NOTE: here we are using the name of the properties and fields in the strings: /// if those are changed for any reason, the strings in this method should reflect that /// </summary> /// <param name="formData">The collection representing the data from the form</param> /// <returns>The list of view models</returns> public List <ScheduledTaskViewModel> GetTaskViewModelsFromForm(NameValueCollection formData) { var keys = formData.AllKeys.Where(k => k.IndexOf("allTasks[") == 0).ToArray(); List <ScheduledTaskViewModel> vmsForTasks = new List <ScheduledTaskViewModel>(); int nVms = keys.Where(x => x.EndsWith("].Id")).Count(); for (int i = 0; i < nVms; i++) { string kk = (keys.Where(x => x.EndsWith("].Id"))).ToArray()[i]; int index = int.Parse(kk.Split(new string[] { "[", "]" }, StringSplitOptions.RemoveEmptyEntries)[1]); string thisObject = String.Format("allTasks[{0}].", index); DateTime?inputDate; try { string formDate = formData[thisObject + "ScheduledStartUTCEditor.Date"]; string formTime = formData[thisObject + "ScheduledStartUTCEditor.Time"]; //inputDate = _dateServices.ConvertFromLocalizedString(formDate, formTime); inputDate = _dateLocalization.StringToDatetime(formDate, formTime); } catch (Exception) { inputDate = null; } vmsForTasks.Add(new ScheduledTaskViewModel(_orchardServices, _dateServices) { Id = int.Parse(formData[thisObject + "Id"]), SignalName = formData[thisObject + "SignalName"], ScheduledStartUTC = inputDate, PeriodicityTime = int.Parse(formData[thisObject + "PeriodicityTime"]), ExecutionType = EnumExtension <ExecutionTypes> .ParseEnum(formData[thisObject + "ExecutionType"]), PeriodicityUnit = EnumExtension <TimeUnits> .ParseEnum(formData[thisObject + "PeriodicityUnit"]), ContentItemId = int.Parse(formData[thisObject + "ContentItemId"]), Running = int.Parse(formData[thisObject + "Running"]), Delete = Convert.ToBoolean(formData[thisObject + "Delete"]), Scheduling = Convert.ToBoolean(formData[thisObject + "Scheduling"]), Autodestroy = (formData[thisObject + "Autodestroy"]).Contains("true"), LongTask = (formData[thisObject + "LongTask"]).Contains("true") }); } return(vmsForTasks); }
/// <summary> /// Runs upon the POST of the editor view. /// </summary> /// <param name="part">The part.</param> /// <param name="updater">The updater.</param> /// <param name="shapeHelper">The shape helper.</param> protected override DriverResult Editor(ActivityPart part, IUpdateModel updater, dynamic shapeHelper) { var partSettings = part.Settings.GetModel <ActivityPartSettings>(); ActivityViewModel activityVM = new ActivityViewModel(); if (updater.TryUpdateModel(activityVM, Prefix, null, null)) { if (partSettings.DateTimeType == DateTimeTypes.FromToOnSameDate) { activityVM.DateEnd = activityVM.DateStart; } //Mapper.CreateMap<ActivityViewModel, ActivityPart>() // .ForMember(dest => dest.DateTimeStart, opt => opt.Ignore()) // .ForMember(dest => dest.DateTimeEnd, opt => opt.Ignore()) // .ForMember(dest => dest.RepeatEndDate, opt => opt.Ignore()) // .ForMember(dest => dest.RepeatDetails, opt => opt.Ignore()); //Automapper has changed its static API since v4.2 Mapper.Initialize(cfg => { cfg.CreateMap <ActivityViewModel, ActivityPart>() .ForMember(dest => dest.DateTimeStart, opt => opt.Ignore()) .ForMember(dest => dest.DateTimeEnd, opt => opt.Ignore()) .ForMember(dest => dest.RepeatEndDate, opt => opt.Ignore()) .ForMember(dest => dest.RepeatDetails, opt => opt.Ignore()) //ContentPart has a Settings property, that would clash with the Settings property from ActivityViewModel .ForMember(dest => dest.Settings, opt => opt.Ignore()); }); Mapper.Map(activityVM, part); if (!partSettings.UseRecurrences) { part.Repeat = false; } if (!String.IsNullOrWhiteSpace(activityVM.DateStart) && (!String.IsNullOrWhiteSpace(activityVM.DateEnd) || partSettings.SingleDate) && (activityVM.AllDay || (!activityVM.AllDay && !String.IsNullOrWhiteSpace(activityVM.TimeStart) && !String.IsNullOrWhiteSpace(activityVM.TimeEnd)))) { try { DateTime?startDate; DateTime?endDate; if (activityVM.AllDay) { startDate = _dataLocalization.StringToDatetime(activityVM.DateStart, ""); endDate = _dataLocalization.StringToDatetime(activityVM.DateEnd, ""); } else { startDate = _dataLocalization.StringToDatetime(activityVM.DateStart, activityVM.TimeStart).Value; endDate = _dataLocalization.StringToDatetime(activityVM.DateEnd, activityVM.TimeEnd).Value; if (partSettings.DateTimeType == DateTimeTypes.FromToOnSameDate && startDate.Value.TimeOfDay > endDate.Value.TimeOfDay) { endDate = endDate.Value.AddDays(1); } } if (!partSettings.SingleDate && startDate.HasValue && endDate.HasValue && DateTime.Compare(startDate.Value, endDate.Value) > 0) { updater.AddModelError(Prefix + "DateFormatError", T("The ending date is greater than the starting date.")); } part.DateTimeStart = startDate; part.DateTimeEnd = endDate; if (partSettings.SingleDate) { part.DateTimeEnd = part.DateTimeStart; } }catch (OrchardException) { updater.AddModelError(Prefix + "DateFormatError", T("The starting date or ending date are not valid.")); } } else { updater.AddModelError(Prefix + "DateRequiredError", T("The starting date and ending date of the event are required.")); } if (part.Repeat) { try{ part.RepeatEndDate = _dataLocalization.StringToDatetime(activityVM.RepeatEndDate, ""); } catch (OrchardException) { updater.AddModelError(Prefix + "DateRepeateFormatError", T("The repeat date is not valid.")); } if (part.RepeatEnd && part.RepeatEndDate == null) { updater.AddModelError(Prefix + "DateRepeateRequiredError", T("The repeat end date is required.")); } string repeatDetails = ""; if (activityVM.RepeatType == "W") { if (activityVM.Monday) { repeatDetails += DayOfWeek.Monday + ","; } if (activityVM.Tuesday) { repeatDetails += DayOfWeek.Tuesday + ","; } if (activityVM.Wednesday) { repeatDetails += DayOfWeek.Wednesday + ","; } if (activityVM.Thursday) { repeatDetails += DayOfWeek.Thursday + ","; } if (activityVM.Friday) { repeatDetails += DayOfWeek.Friday + ","; } if (activityVM.Saturday) { repeatDetails += DayOfWeek.Saturday + ","; } if (activityVM.Sunday) { repeatDetails += DayOfWeek.Sunday + ","; } } else if (activityVM.RepeatType == "M") { if (activityVM.RepeatByDayNumber) { repeatDetails = "DayNum"; } else { repeatDetails = "DayWeek"; } } if (repeatDetails.EndsWith(",")) { repeatDetails = repeatDetails.Substring(0, repeatDetails.Length - 1); } part.RepeatDetails = repeatDetails; } } return(Editor(part, shapeHelper)); }
public ActionResult List(ListContentsViewModelExtension model, PagerParameters pagerParameters) { Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); var versionOptions = VersionOptions.Latest; switch (model.Options.ContentsStatus) { case ContentsStatus.Published: versionOptions = VersionOptions.Published; break; case ContentsStatus.Draft: versionOptions = VersionOptions.Draft; break; case ContentsStatus.AllVersions: versionOptions = VersionOptions.AllVersions; break; default: versionOptions = VersionOptions.Latest; break; } var query = _contentManager.Query(versionOptions, GetListableTypes(false).Select(ctd => ctd.Name).ToArray()); //the lQuery is used only in the case where we have the language queries, but since we cannot clone IContentQuery objects, //we create it here and build is as we build the other var lQuery = _contentManager.Query(versionOptions, GetListableTypes(false).Select(ctd => ctd.Name).ToArray()); if (!string.IsNullOrEmpty(model.TypeName)) { var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(model.TypeName); if (contentTypeDefinition == null) { return(HttpNotFound()); } model.TypeDisplayName = !string.IsNullOrWhiteSpace(contentTypeDefinition.DisplayName) ? contentTypeDefinition.DisplayName : contentTypeDefinition.Name; query = query.ForType(model.TypeName); lQuery = lQuery.ForType(model.TypeName); } // FILTER QUERIES: START // // terms query if (model.AdvancedOptions.SelectedTermId > 0) { var termId = model.AdvancedOptions.SelectedTermId; query = query.Join <TermsPartRecord>().Where(x => x.Terms.Any(a => a.TermRecord.Id == termId)); lQuery = lQuery.Join <TermsPartRecord>().Where(x => x.Terms.Any(a => a.TermRecord.Id == termId)); } // owner query if ( //user cannot see everything by default ( !Services.Authorizer.Authorize(AdvancedSearchPermissions.SeesAllContent) || (Services.Authorizer.Authorize(AdvancedSearchPermissions.SeesAllContent) && model.AdvancedOptions.OwnedByMeSeeAll) ) && ( //user has either limitation ((Services.Authorizer.Authorize(AdvancedSearchPermissions.MayChooseToSeeOthersContent)) && (model.AdvancedOptions.OwnedByMe)) || (Services.Authorizer.Authorize(AdvancedSearchPermissions.CanSeeOwnContents) && !Services.Authorizer.Authorize(AdvancedSearchPermissions.MayChooseToSeeOthersContent)) ) ) { //this user can only see the contents they own var lowerName = Services.WorkContext.CurrentUser.UserName.ToLowerInvariant(); var email = Services.WorkContext.CurrentUser.Email; var user = _contentManager.Query <UserPart, UserPartRecord>().Where(u => u.NormalizedUserName == lowerName || u.Email == email).List().FirstOrDefault(); query = query.Join <CommonPartRecord>().Where(x => x.OwnerId == user.Id); lQuery = lQuery.Join <CommonPartRecord>().Where(x => x.OwnerId == user.Id); } else if (!String.IsNullOrWhiteSpace(model.AdvancedOptions.SelectedOwner)) { var lowerName = model.AdvancedOptions.SelectedOwner == null ? "" : model.AdvancedOptions.SelectedOwner.ToLowerInvariant(); var email = model.AdvancedOptions.SelectedOwner; var user = _contentManager.Query <UserPart, UserPartRecord>().Where(u => u.NormalizedUserName == lowerName || u.Email == email).List().FirstOrDefault(); if (user != null) { query = query.Join <CommonPartRecord>().Where(x => x.OwnerId == user.Id); lQuery = lQuery.Join <CommonPartRecord>().Where(x => x.OwnerId == user.Id); } else { _notifier.Add(NotifyType.Warning, T("No user found. Ownership filter not applied.")); } } //date query if (model.AdvancedOptions.SelectedFromDate != null || model.AdvancedOptions.SelectedToDate != null) { //set default dates for From and To if they are null. var fromD = _dataLocalization.StringToDatetime(model.AdvancedOptions.SelectedFromDate, "") ?? _dataLocalization.StringToDatetime("09/05/1985", ""); var toD = _dataLocalization.StringToDatetime(model.AdvancedOptions.SelectedToDate, "") ?? DateTime.Now; if (model.AdvancedOptions.DateFilterType == DateFilterOptions.Created) { query = query.Join <CommonPartRecord>().Where(x => x.CreatedUtc >= fromD && x.CreatedUtc <= toD); lQuery = lQuery.Join <CommonPartRecord>().Where(x => x.CreatedUtc >= fromD && x.CreatedUtc <= toD); } else if (model.AdvancedOptions.DateFilterType == DateFilterOptions.Modified) { query = query.Join <CommonPartRecord>().Where(x => x.ModifiedUtc >= fromD && x.ModifiedUtc <= toD); lQuery = lQuery.Join <CommonPartRecord>().Where(x => x.ModifiedUtc >= fromD && x.ModifiedUtc <= toD); } else if (model.AdvancedOptions.DateFilterType == DateFilterOptions.Published) { query = query.Join <CommonPartRecord>().Where(x => x.PublishedUtc >= fromD && x.PublishedUtc <= toD); lQuery = lQuery.Join <CommonPartRecord>().Where(x => x.PublishedUtc >= fromD && x.PublishedUtc <= toD); } } // Has media query if (model.AdvancedOptions.HasMedia) { var allCt = GetListableTypes(false); var listFields = new List <string>(); foreach (var ct in allCt) { var allMediaFld = _contentDefinitionService.GetType(ct.Name).Fields.Where(w => w._Definition.FieldDefinition.Name == "MediaLibraryPickerField"); var allFieldNames = allMediaFld.Select(s => ct.Name + "." + s.Name + "."); listFields.AddRange(allFieldNames); } query = query.Join <FieldIndexPartRecord>().Where(w => w.StringFieldIndexRecords.Any( w2 => listFields.Contains(w2.PropertyName) && w2.Value != "" )); lQuery = lQuery.Join <FieldIndexPartRecord>().Where(w => w.StringFieldIndexRecords.Any( w2 => listFields.Contains(w2.PropertyName) && w2.Value != "" )); } // Extended Status query if (!String.IsNullOrWhiteSpace(model.AdvancedOptions.SelectedStatus)) { query = query.Join <FieldIndexPartRecord>().Where(w => w.StringFieldIndexRecords.Any( w2 => w2.PropertyName == "PublishExtensionPart.PublishExtensionStatus." && w2.Value == model.AdvancedOptions.SelectedStatus )); lQuery = lQuery.Join <FieldIndexPartRecord>().Where(w => w.StringFieldIndexRecords.Any( w2 => w2.PropertyName == "PublishExtensionPart.PublishExtensionStatus." && w2.Value == model.AdvancedOptions.SelectedStatus )); } // FILTER QUERIES: END // switch (model.Options.OrderBy) { case ContentsOrder.Modified: //query = query.OrderByDescending<ContentPartRecord, int>(ci => ci.ContentItemRecord.Versions.Single(civr => civr.Latest).Id); query = query.OrderByDescending <CommonPartRecord>(cr => cr.ModifiedUtc); lQuery = lQuery.OrderByDescending <CommonPartRecord>(cr => cr.ModifiedUtc); break; case ContentsOrder.Published: query = query.OrderByDescending <CommonPartRecord>(cr => cr.PublishedUtc); lQuery = lQuery.OrderByDescending <CommonPartRecord>(cr => cr.PublishedUtc); break; case ContentsOrder.Created: //query = query.OrderByDescending<ContentPartRecord, int>(ci => ci.Id); query = query.OrderByDescending <CommonPartRecord>(cr => cr.CreatedUtc); lQuery = lQuery.OrderByDescending <CommonPartRecord>(cr => cr.CreatedUtc); break; } model.Options.SelectedFilter = model.TypeName; model.Options.FilterOptions = GetListableTypes(false) .Select(ctd => new KeyValuePair <string, string>(ctd.Name, ctd.DisplayName)) .ToList().OrderBy(kvp => kvp.Value); // FILTER MODELS: START // // language filter model model.AdvancedOptions.LanguageOptions = _commonService.ListCultures().Select(x => new KeyValuePair <int, string>(x.Id, x.Culture)); // taxonomy filter model var termList = new List <KeyValuePair <int, string> >(); foreach (var taxonomy in _taxonomyService.GetTaxonomies()) { termList.Add(new KeyValuePair <int, string>(-1, taxonomy.Name)); foreach (var term in _taxonomyService.GetTerms(taxonomy.Id)) { var gap = new string('-', term.GetLevels()); if (gap.Length > 0) { gap += " "; } termList.Add(new KeyValuePair <int, string>(term.Id, gap + term.Name)); } } model.AdvancedOptions.TaxonomiesOptions = termList; // extended status var partDefinition = _contentDefinitionService.GetPart("PublishExtensionPart"); if (partDefinition != null) { var partField = partDefinition.Fields.Where(w => w.Name == "PublishExtensionStatus").SingleOrDefault(); var settings = partField.Settings.GetModel <EnumerationFieldSettings>().Options; string[] options = (!String.IsNullOrWhiteSpace(settings)) ? settings.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.None) : null; model.AdvancedOptions.StatusOptions = options.Select(s => new KeyValuePair <string, string>(s, T(s).Text)); } #region TEST OF CPF QUERIES //if (model.AdvancedOptions.CPFOwnerId != null) { // var item = _contentManager.Get((int)model.AdvancedOptions.CPFOwnerId); // var parts = item.Parts; // list = Shape.List(); // foreach (var part in parts) { // foreach (var field in part.Fields) { // if (field.FieldDefinition.Name == "ContentPickerField") { // bool noName = String.IsNullOrWhiteSpace(model.AdvancedOptions.CPFName); // if (noName || (!noName && field.Name == model.AdvancedOptions.CPFName)) { // var relatedItems = _contentManager.GetMany<ContentItem>((IEnumerable<int>)field.GetType().GetProperty("Ids").GetValue(field), VersionOptions.Latest, QueryHints.Empty); // list.AddRange(relatedItems.Select(ci => _contentManager.BuildDisplay(ci, "SummaryAdmin"))); // } // } // } // } //} if (model.AdvancedOptions.CPFIdToSearch != null && !String.IsNullOrWhiteSpace(model.AdvancedOptions.CPFName)) { //given an Id, search for all items that have a Content Picker Field whose PropertyName is PCFName and that have the //Id among the corresponding values. string fieldName = (string)model.AdvancedOptions.CPFName; query = query.Join <FieldIndexPartRecord>() .Where(fip => fip.StringFieldIndexRecords .Any(sfi => sfi.PropertyName.Contains(fieldName) && sfi.LatestValue.Contains("{" + model.AdvancedOptions.CPFIdToSearch.ToString() + "}") ) ); lQuery = lQuery.Join <FieldIndexPartRecord>() .Where(fip => fip.StringFieldIndexRecords .Any(sfi => sfi.PropertyName.Contains(fieldName) && sfi.LatestValue.Contains("{" + model.AdvancedOptions.CPFIdToSearch.ToString() + "}") ) ); } #endregion // FILTER MODELS: END // //EXECUTE QUERIES var pagerShape = Shape.Pager(pager).TotalItemCount(0); var list = Shape.List(); IEnumerable <ContentItem> pageOfContentItems = (IEnumerable <ContentItem>)null; //Stopwatch sw = Stopwatch.StartNew(); //the user may not have permission to see anything: in that case, do not execute the query #region original query //this is roughly 1000 slower than the variant below //if (Services.Authorizer.Authorize(AdvancedSearchPermissions.CanSeeOwnContents)) { // // language query // //For any language query, remember that Orchard's localization table, as of Orchard 1.8, has an issue where the content // //created but never translated does not have the default Culture assigned to it. // Expression<Func<LocalizationPartRecord, bool>> selLangPredicate = null; // if (model.AdvancedOptions.SelectedLanguageId > 0) { // bool siteCultureSelected = _cultureManager.GetSiteCulture() == _cultureManager.GetCultureById(model.AdvancedOptions.SelectedLanguageId).Culture; // if (siteCultureSelected) { // selLangPredicate = // x => x.CultureId == model.AdvancedOptions.SelectedLanguageId || // x.CultureId == 0; // } else { // selLangPredicate = // x => x.CultureId == model.AdvancedOptions.SelectedLanguageId; // } // } // if (model.AdvancedOptions.SelectedLanguageId > 0) { // query = query.Join<LocalizationPartRecord>().Where(selLangPredicate); // } // //if we want only items that do not have a specific translation, we have to do things differently, // //because the check is done after the query. Hence, for example, we cannot directly page. // if (model.AdvancedOptions.SelectedUntranslatedLanguageId > 0) { // var allCi = query.List(); // //for (int i = 0; i < allCi.Count(); i++) { //this loop is used to test null conditions and other stuff like that while debugging // // var ci = allCi.ElementAt(i); // // if (ci.Is<LocalizationPart>()) { // // var lci = _localizationService.GetLocalizations(ci, versionOptions); // // var clci = lci.Count(); // // var bo = lci.Any(li => li.Culture.Id == model.AdvancedOptions.SelectedUntranslatedLanguageId); // // } // //} // var untranslatedCi = allCi // .Where(x => // x.Is<LocalizationPart>() && //the content is translatable // ( // x.As<LocalizationPart>().Culture == null || //this is the case where the content was created and never translated to any other culture. // x.As<LocalizationPart>().Culture.Id != model.AdvancedOptions.SelectedUntranslatedLanguageId //not a content in the language in which we are looking translations // ) && // _localizationService.GetLocalizations(x, versionOptions) != null && // !_localizationService.GetLocalizations(x, versionOptions).Any(li => // li.Culture != null && // li.Culture.Id == model.AdvancedOptions.SelectedUntranslatedLanguageId // ) // ); // //.Where(x => // // x.Is<LocalizationPart>() && //some content items may not be translatable // // ( // // (x.As<LocalizationPart>().Culture != null && x.As<LocalizationPart>().Culture.Id != model.AdvancedOptions.SelectedUntranslatedLanguageId) || // // (x.As<LocalizationPart>().Culture == null) //this is the case where the content was created and never translated to any other culture. // // //In that case, in Orchard 1.8, no culture is directly assigned to it, even though the default culture is assumed. // // ) && // // x.As<LocalizationPart>().MasterContentItem == null && // // !allCi.Any(y => // // y.Is<LocalizationPart>() && // // (y.As<LocalizationPart>().MasterContentItem == x || y.As<LocalizationPart>().MasterContentItem == x.As<LocalizationPart>().MasterContentItem) && // // y.As<LocalizationPart>().Culture.Id == model.AdvancedOptions.SelectedUntranslatedLanguageId // // ) // //); // //Paging // pagerShape = Shape.Pager(pager).TotalItemCount(untranslatedCi.Count()); // int pSize = pager.PageSize != 0 ? pager.PageSize : untranslatedCi.Count(); // pageOfContentItems = untranslatedCi // .Skip(pager.GetStartIndex()) // .Take((pager.GetStartIndex() + pSize) > untranslatedCi.Count() ? // untranslatedCi.Count() - pager.GetStartIndex() : // pSize) // .ToList(); // } else { // pagerShape = Shape.Pager(pager).TotalItemCount(query.Count()); // pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList(); // } //} else { // Services.Notifier.Error(T("Not authorized to visualize any item.")); //} #endregion if (Services.Authorizer.Authorize(AdvancedSearchPermissions.CanSeeOwnContents)) { // language queries //For any language query, remember that Orchard's localization table, as of Orchard 1.8, has an issue where the content //created but never translated does not have the default Culture assigned to it. Expression <Func <LocalizationPartRecord, bool> > selLangPredicate = null; if (model.AdvancedOptions.SelectedLanguageId > 0) { bool siteCultureSelected = _cultureManager.GetSiteCulture() == _cultureManager.GetCultureById(model.AdvancedOptions.SelectedLanguageId).Culture; if (siteCultureSelected) { selLangPredicate = x => x.CultureId == model.AdvancedOptions.SelectedLanguageId || x.CultureId == 0; } else { selLangPredicate = x => x.CultureId == model.AdvancedOptions.SelectedLanguageId; } query = query.Join <LocalizationPartRecord>().Where(selLangPredicate); } Expression <Func <LocalizationPartRecord, bool> > untranLangPredicate = null; if (model.AdvancedOptions.SelectedUntranslatedLanguageId > 0) { bool siteCultureSelected = _cultureManager.GetSiteCulture() == _cultureManager.GetCultureById(model.AdvancedOptions.SelectedUntranslatedLanguageId).Culture; if (siteCultureSelected) { untranLangPredicate = x => x.CultureId == model.AdvancedOptions.SelectedUntranslatedLanguageId || x.CultureId == 0; } else { untranLangPredicate = x => x.CultureId == model.AdvancedOptions.SelectedUntranslatedLanguageId; } lQuery = lQuery.Join <LocalizationPartRecord>().Where(untranLangPredicate); var lRes = lQuery.List(); var masters = lRes.Where(x => x.As <LocalizationPart>().Record.MasterContentItemId != 0).Select(x => x.As <LocalizationPart>().Record.MasterContentItemId).ToList(); var items = lRes.Select(x => x.Id).ToList(); Expression <Func <LocalizationPartRecord, bool> > sulPredicate = x => x.CultureId != model.AdvancedOptions.SelectedUntranslatedLanguageId && !masters.Contains(x.Id) && !masters.Contains(x.MasterContentItemId) && !items.Contains(x.MasterContentItemId); query = query.Join <LocalizationPartRecord>().Where(sulPredicate); } pagerShape = Shape.Pager(pager).TotalItemCount(query.Count()); pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList(); } else { Services.Notifier.Error(T("Not authorized to visualize any item.")); } //sw.Stop(); //Services.Notifier.Error(new LocalizedString(sw.Elapsed.TotalMilliseconds.ToString())); if (pageOfContentItems != null) { list.AddRange(pageOfContentItems.Select(ci => _contentManager.BuildDisplay(ci, "SummaryAdmin"))); } var viewModel = Shape.ViewModel() .ContentItems(list) .Pager(pagerShape) .Options(model.Options) .AdvancedOptions(model.AdvancedOptions) .TypeDisplayName(model.TypeDisplayName ?? ""); return(View(viewModel)); }