public async Task <QueryResult <IDictionary <string, object> > > QueryDeviceConfigDynamic( DeviceConfigQueryProjection projection, DeviceConfigQueryOptions options, DeviceConfigQueryFilter filter = null, DeviceConfigQuerySort sort = null, DeviceConfigQueryPaging paging = null) { var query = DeviceConfigs; #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 || !DeviceConfigQueryOptions.IsLoadAllAllowed)) { query = query.SelectPage(paging.page, paging.limit); } #endregion } if (options.single_only) { var single = query.SingleOrDefault(); if (single == null) { return(null); } var singleResult = GetDeviceConfigDynamic(single, projection, options); return(new QueryResult <IDictionary <string, object> >() { Single = singleResult }); } var entities = query.ToList(); var list = GetDeviceConfigDynamic(entities, projection, options); var result = new QueryResult <IDictionary <string, object> >(); result.List = list; if (options.count_total) { result.Count = totalCount; } return(result); }
public static IQueryable <DeviceConfig> Filter( this IQueryable <DeviceConfig> query, DeviceConfigQueryFilter filter) { if (filter.id != null) { query = query.Where(o => o.Id == filter.id); } return(query); }
public ValidationData ValidateGetDeviceConfigs( ClaimsPrincipal principal, DeviceConfigQueryFilter filter, DeviceConfigQuerySort sort, DeviceConfigQueryProjection projection, DeviceConfigQueryPaging paging, DeviceConfigQueryOptions options) { return(new ValidationData()); }
public async Task <IActionResult> Get([FromQuery][QueryObject] DeviceConfigQueryFilter filter, [FromQuery] DeviceConfigQuerySort sort, [FromQuery] DeviceConfigQueryProjection projection, [FromQuery] DeviceConfigQueryPaging paging, [FromQuery] DeviceConfigQueryOptions options) { var validationData = _service.ValidateGetDeviceConfigs( User, filter, sort, projection, paging, options); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } var result = await _service.QueryDeviceConfigDynamic( projection, options, filter, sort, paging); if (options.single_only && result == null) { return(NotFound(AppResult.NotFound())); } return(Ok(AppResult.Success(result))); }