Ejemplo n.º 1
0
        public virtual async Task <IList <User> > QueryByParameters(QueryUsersParameters parameters, CancellationToken cancellationToken)
        {
            var orderByProperty = parameters.OrderBy != null
             ? OrderByPropertues.FirstOrDefault(x => x.Equals(parameters.OrderBy, StringComparison.InvariantCultureIgnoreCase))
             : default;

            var result = Items
                         .Values
                         .AsQueryable()
                         .Where(() => !string.IsNullOrEmpty(parameters.Firstname), x => x.FirstName.Contains(parameters.Firstname, StringComparison.InvariantCultureIgnoreCase))
                         .Where(() => !string.IsNullOrEmpty(parameters.Email), x => x.Email.Contains(parameters.Email, StringComparison.InvariantCultureIgnoreCase))
                         .OrderBy(orderByProperty, parameters.IsDescending)
                         .GetPage(parameters.PageSize, parameters.PageIndex);

            return(await Task.FromResult(result));
        }
Ejemplo n.º 2
0
        public virtual async Task <IList <Game> > QueryByParameters(QueryParameters parameters, CancellationToken cancellationToken)
        {
            var orderByProperty = parameters.OrderBy != null
                ? OrderByPropertues.FirstOrDefault(x => x.Equals(parameters.OrderBy, StringComparison.InvariantCultureIgnoreCase))
                : default;

            var result = Items
                         .Values
                         .AsQueryable()
                         .Where(() => !string.IsNullOrEmpty(parameters.Name), x => x.Name.Contains(parameters.Name, StringComparison.InvariantCultureIgnoreCase))
                         .Where(() => !string.IsNullOrEmpty(parameters.Category), x => x.Category.Contains(parameters.Category, StringComparison.InvariantCultureIgnoreCase))
                         .Where(() => !string.IsNullOrEmpty(parameters.Description), x => x.Description.Contains(parameters.Description, StringComparison.InvariantCultureIgnoreCase))
                         .Where(() => parameters.ReleaseDate != null, x => x.ReleaseDate <= parameters.ReleaseDate)
                         .OrderBy(orderByProperty, parameters.IsDescending)
                         .GetPage(parameters.PageSize, parameters.PageIndex);

            return(await Task.FromResult(result));
        }