Exemplo n.º 1
0
 public override Task <IEnumerable <IndividualVariableDto> > Filter([FromBody] CrudFilterModel filterData)
 {
     throw new HttpResponseException
           {
               Value = AjkaExceptions.E0003
           };
 }
Exemplo n.º 2
0
        public async Task <IEnumerable <TEntityDto> > GetFilteredAsync(CrudFilterModel filterData, CancellationToken cancellationToken)
        {
            IEnumerable <TEntity> entities;

            if (filterData.ObjectsPerPage == 0 || filterData.PageNumber == 0)
            {
                entities = await ajkaShopDbContext.Set <TEntity>().AsQueryable()
                           .ToListAsync().ConfigureAwait(false);
            }
            else
            {
                entities = await ajkaShopDbContext.Set <TEntity>().AsQueryable()
                           .Skip(filterData.ObjectsPerPage * (filterData.PageNumber - 1))
                           .Take(filterData.ObjectsPerPage)
                           .ToListAsync().ConfigureAwait(false);
            }
            if (!string.IsNullOrWhiteSpace(filterData.OrderColumn))
            {
                Func <TEntity, Object> orderByFunc = sort => sort.GetType().GetProperty(filterData.OrderColumn)?.GetValue(sort);
                entities = filterData.IsDescendingOrder
                    ? entities.OrderByDescending(orderByFunc)
                    : entities.OrderBy(orderByFunc);
            }
            return(entities != null?_mapper.Map <IEnumerable <TEntityDto> >(entities) : null);
        }
Exemplo n.º 3
0
 public virtual async Task <IEnumerable <TEntityDto> > Filter([FromBody] CrudFilterModel filterData)
 {
     return(await facade.GetFilteredAsync(filterData, CancellationToken.None).ConfigureAwait(false));
 }