protected async Task <List <(FormEditContext editContext, IEnumerable <SectionUI> sections)> > ReloadSectionsAsync(IEnumerable <string> reloadEntityIds, IListUIResolver uiResolver) { if (Sections == null) { return(new List <(FormEditContext editContext, IEnumerable <SectionUI> sections)>()); } var newSections = await Sections.ToListAsync(async x => { if (reloadEntityIds.Contains <string>(x.editContext.Entity.Id !)) { var reloadedEditContext = await PresentationService.GetEntityAsync <GetEntityRequestModel, FormEditContext>(new GetEntityRequestModel { CollectionAlias = x.editContext.CollectionAlias, Id = x.editContext.Entity.Id, ParentPath = x.editContext.Parent?.GetParentPath(), UsageType = x.editContext.UsageType, VariantAlias = x.editContext.EntityVariantAlias }); return(reloadedEditContext, await uiResolver.GetSectionsForEditContextAsync(reloadedEditContext)); }
protected async Task <(ListContext listContext, List <(FormEditContext editContext, IEnumerable <SectionUI> sections)> sections)> LoadSectionsAsync(ListUI listUI, IListUIResolver uiResolver) { var query = Query.Create(listUI.PageSize, CurrentState.CurrentPage, CurrentState.SearchTerm, CurrentState.ActiveTab); query.CollectionAlias = CurrentState.CollectionAlias; if (listUI.OrderBys != null) { query.SetOrderBys(listUI.OrderBys); } var request = CurrentState.Related != null ? (GetEntitiesRequestModel) new GetEntitiesOfRelationRequestModel { CollectionAlias = CurrentState.CollectionAlias, Query = query, Related = CurrentState.Related, UsageType = CurrentState.UsageType, VariantAlias = CurrentState.VariantAlias } : (GetEntitiesRequestModel) new GetEntitiesOfParentRequestModel { CollectionAlias = CurrentState.CollectionAlias, ParentPath = CurrentState.ParentPath, Query = query, UsageType = CurrentState.UsageType, VariantAlias = CurrentState.VariantAlias }; var listContext = await PresentationService.GetEntitiesAsync <GetEntitiesRequestModel, ListContext>(request); var sections = await listContext.EditContexts.ToListAsync(async editContext => (editContext, await uiResolver.GetSectionsForEditContextAsync(editContext))); if (!query.MoreDataAvailable) { CurrentState.MaxPage = CurrentState.CurrentPage; if (CurrentState.CurrentPage > 1 && sections?.Any() != true) { CurrentState.CurrentPage--; CurrentState.MaxPage = null; return(await LoadSectionsAsync(listUI, uiResolver)); } } if (CurrentState.MaxPage == CurrentState.CurrentPage && query.MoreDataAvailable) { CurrentState.MaxPage = null; } return(listContext, sections); }