public EntitiesChangesModel(
     Entity entity,
     PagedRecords pagedRecords,
     TableInfo tableInfo)
     : base(entity, pagedRecords, tableInfo)
 {
 }
Exemple #2
0
 public PagedRecords GetRecords(
     Entity entity,
     NameValueCollection request,
     TableInfo tableInfo)
 {
     return GetRecords(entity, request, tableInfo, null);
 }
 public EntitiesIndexModel(
     Entity entity,
     PagedRecords pagedRecords,
     TableInfo tableInfo)
 {
     Records = pagedRecords.Records;
     Columns = entity.DisplayProperties
         .Select(x => new Column(x, tableInfo.Order, tableInfo.OrderDirection)).ToList();
     Entity = entity;
     Pager =
         new PagerInfo(tableInfo.PerPage, tableInfo.Page, pagedRecords.TotalItems);
     Filters = pagedRecords.Filters.Where(x => x.IsVisible).ToList();
     TableInfo = tableInfo;
 }
Exemple #4
0
        public IList<ChangeRow> GetLastChanges(int quantity)
        {
            var changeEntity = _admin.ChangeEntity;
            if (changeEntity == null)
            {
                return new List<ChangeRow>();
            }

            var tableInfo = new TableInfo
            {
                Page = 1,
                PerPage = quantity,
                Order = nameof(IEntityChange.ChangedOn),
                OrderDirection = "desc"
            };
            var pagedRecords = GetRecords(changeEntity, null, tableInfo);

            return pagedRecords.Records.Select(x => new ChangeRow(x)).ToList();
        }
Exemple #5
0
 public PagedRecords GetChanges(
     Entity entityChangesFor,
     string key,
     NameValueCollection request,
     TableInfo tableInfo)
 {
     var changeEntity = _admin.ChangeEntity;
     return GetRecords(changeEntity, request, tableInfo, filters =>
     {
         if (key.IsNullOrWhiteSpace() == false)
         {
             filters.Add(new ForeignEntityFilter(changeEntity["EntityKey"], key));
         }
         if (entityChangesFor != null)
         {
             filters.Add(new ChangeEntityFilter(changeEntity["EntityName"], entityChangesFor.Name));
         }
     });
 }
        public virtual ActionResult Index(string entityName, TableInfo tableInfo)
        {
            var entity = _admin.GetEntity(entityName);
            if (entity == null)
            {
                throw new NoNullAllowedException("entity is null");
            }
            var pagedRecords = _recordsService.GetRecords(entity, Request.QueryString, tableInfo);
            if (pagedRecords.Records.IsNullOrEmpty() && tableInfo.Page > 1)
            {
                return Redirect(Url.PageUrl(1));
            }

            var model = new EntitiesIndexModel(entity, pagedRecords, tableInfo)
            {
                Configuration = _configuration,
                ChangeEnabled = _admin.ChangeEntity != null
            };

            return View(model);
        }
        public virtual ActionResult Changes(string entityName, string key, TableInfo tableInfo)
        {
            var entityChangesFor = _admin.GetEntity(entityName);
            var pagedRecords = _recordsService
                .GetChanges(entityChangesFor, key, Request.QueryString, tableInfo);
            if (pagedRecords.Records.IsNullOrEmpty() && tableInfo.Page > 1)
            {
                return Redirect(Url.PageUrl(1));
            }

            var model = new EntitiesChangesModel(
                _admin.ChangeEntity,
                pagedRecords,
                tableInfo)
            {
                EntityChangesFor = entityChangesFor,
                Key = key,
                Configuration = _configuration,
                ChangeEnabled = _admin.ChangeEntity != null
            };

            return View(model);
        }
Exemple #8
0
        private PagedRecords GetRecords(
            Entity entity,
            NameValueCollection request,
            TableInfo tableInfo,
            Action<IList<BaseFilter>> filtersMutator)
        {
            AddDefaultOrder(entity, tableInfo);

            var filters = BuildFilters(entity, request, filtersMutator).ToList();

            var pagedRecords = _entitiesSource.GetRecords(
                entity,
                filters,
                tableInfo.SearchQuery,
                tableInfo.Order,
                tableInfo.OrderDirection,
                false,
                tableInfo.Page,
                tableInfo.PerPage);
            pagedRecords.Filters = filters;

            return pagedRecords;
        }
Exemple #9
0
        private void AddDefaultOrder(Entity entity, TableInfo tableInfo)
        {
            if (tableInfo.Order.HasValue())
                return;

            var defaultOrderProperty = entity.Properties
                .FirstOrDefault(x => x.DefaultOrder.HasValue);
            if (defaultOrderProperty != null)
            {
                tableInfo.Order = defaultOrderProperty.Name;
                tableInfo.OrderDirection =
                    defaultOrderProperty.DefaultOrder.Value.ToString().ToLower();
            }
        }