public IActionResult Index(RibbonButtonModel model) { if (model.EntityId.Equals(Guid.Empty)) { return(NotFound()); } var entity = _entityFinder.FindById(model.EntityId); if (entity == null) { return(NotFound()); } model.Entity = entity; if (!model.LoadData) { return(DynamicResult(model)); } FilterContainer <RibbonButton.Domain.RibbonButton> filter = FilterContainerBuilder.Build <RibbonButton.Domain.RibbonButton>(); filter.And(n => n.EntityId == model.EntityId); if (model.ShowArea.HasValue) { filter.And(n => n.ShowArea == model.ShowArea.Value); } if (model.Label.IsNotEmpty()) { filter.And(n => n.Label.Like(model.Label)); } if (model.GetAll) { model.Page = 1; model.PageSize = WebContext.PlatformSettings.MaxFetchRecords; } else if (!model.PageSizeBySeted && CurrentUser.UserSettings.PagingLimit > 0) { model.PageSize = CurrentUser.UserSettings.PagingLimit; } if (!model.IsSortBySeted) { model.SortBy = "showarea"; } model.PageSize = model.PageSize > WebContext.PlatformSettings.MaxFetchRecords ? WebContext.PlatformSettings.MaxFetchRecords : model.PageSize; PagedList <RibbonButton.Domain.RibbonButton> result = _ribbonButtonFinder.QueryPaged(x => x .Page(model.Page, model.PageSize) .Where(filter) .Sort(n => n.OnFile(model.SortBy).ByDirection(model.SortDirection)) ); model.Items = result.Items; model.TotalItems = result.TotalItems; model.SolutionId = SolutionId.Value; return(DynamicResult(model)); }
public IActionResult Get([FromQuery] RibbonButtonModel model) { if (model.EntityId.Equals(Guid.Empty)) { return(NotFound()); } var entity = _entityFinder.FindById(model.EntityId); if (entity == null) { return(NotFound()); } model.Entity = entity; FilterContainer <RibbonButton.Domain.RibbonButton> filter = FilterContainerBuilder.Build <RibbonButton.Domain.RibbonButton>(); filter.And(n => n.EntityId == model.EntityId); if (model.ShowArea.HasValue) { filter.And(n => n.ShowArea == model.ShowArea.Value); } if (model.Label.IsNotEmpty()) { filter.And(n => n.Label.Like(model.Label)); } if (model.GetAll) { model.Page = 1; model.PageSize = 25000; } else if (CurrentUser.UserSettings.PagingLimit > 0) { model.PageSize = CurrentUser.UserSettings.PagingLimit; } PagedList <RibbonButton.Domain.RibbonButton> result = _ribbonButtonFinder.QueryPaged(x => x .Page(model.Page, model.PageSize) .Where(filter) .Sort(n => n.OnFile(model.SortBy).ByDirection(model.SortDirection)) ); model.Items = result.Items; model.TotalItems = result.TotalItems; model.SolutionId = SolutionId.Value; return(JOk(model)); }
public string GetXml(Guid solutionId) { StringBuilder result = new StringBuilder(); var pageSize = 100; var page = 1; long totalItems = pageSize; while (totalItems == pageSize) { var data = _ribbonButtonFinder.QueryPaged(x => x.Page(page, pageSize), solutionId, true); totalItems = data.TotalItems; if (totalItems > 0) { result.Append(data.Items.SerializeToXml()); } page++; } return(result.ToString()); }