Exemple #1
0
        public async Task <QueryResult <IDictionary <string, object> > > QueryAppClientDynamic(
            AppClientQueryProjection projection,
            AppClientQueryOptions options,
            AppClientQueryFilter filter = null,
            AppClientQuerySort sort     = null,
            AppClientQueryPaging paging = null)
        {
            var query = AppClients;

            #region General
            if (filter != null)
            {
                query = query.Filter(filter);
            }
            query = query.Project(projection);
            int?totalCount = null;
            if (options.count_total)
            {
                totalCount = query.Count();
            }
            #endregion
            if (!options.single_only)
            {
                #region List query
                if (sort != null)
                {
                    query = query.Sort(sort);
                }
                if (paging != null && (!options.load_all || !AppClientQueryOptions.IsLoadAllAllowed))
                {
                    query = query.SelectPage(paging.page, paging.limit);
                }
                #endregion
            }

            if (options.single_only)
            {
                var single = query.SingleOrDefault();
                if (single == null)
                {
                    return(null);
                }
                var singleResult = GetAppClientDynamic(single, projection, options);
                return(new QueryResult <IDictionary <string, object> >()
                {
                    Single = singleResult
                });
            }
            var entities = query.ToList();
            var list     = GetAppClientDynamic(entities, projection, options);
            var result   = new QueryResult <IDictionary <string, object> >();
            result.List = list;
            if (options.count_total)
            {
                result.Count = totalCount;
            }
            return(result);
        }
Exemple #2
0
 public static IQueryable <AppClient> Filter(
     this IQueryable <AppClient> query, AppClientQueryFilter filter)
 {
     if (filter.id != null)
     {
         query = query.Where(o => o.Id == filter.id);
     }
     return(query);
 }
Exemple #3
0
 public ValidationData ValidateGetAppClients(
     ClaimsPrincipal principal,
     AppClientQueryFilter filter,
     AppClientQuerySort sort,
     AppClientQueryProjection projection,
     AppClientQueryPaging paging,
     AppClientQueryOptions options)
 {
     return(new ValidationData());
 }
Exemple #4
0
        public async Task <IActionResult> Get([FromQuery][QueryObject] AppClientQueryFilter filter,
                                              [FromQuery] AppClientQuerySort sort,
                                              [FromQuery] AppClientQueryProjection projection,
                                              [FromQuery] AppClientQueryPaging paging,
                                              [FromQuery] AppClientQueryOptions options)
        {
            var validationData = _service.ValidateGetAppClients(
                User, filter, sort, projection, paging, options);

            if (!validationData.IsValid)
            {
                return(BadRequest(AppResult.FailValidation(data: validationData)));
            }
            var result = await _service.QueryAppClientDynamic(
                projection, options, filter, sort, paging);

            if (options.single_only && result == null)
            {
                return(NotFound(AppResult.NotFound()));
            }
            return(Ok(AppResult.Success(result)));
        }