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));
        }
Beispiel #2
0
        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));
        }