public async Task <QueryResult <IDictionary <string, object> > > QueryProductionBatchDynamic( ProductionBatchQueryProjection projection, ProductionBatchQueryOptions options, ProductionBatchQueryFilter filter = null, ProductionBatchQuerySort sort = null, ProductionBatchQueryPaging paging = null) { var query = ProductionBatchs; #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 || !ProductionBatchQueryOptions.IsLoadAllAllowed)) { query = query.SelectPage(paging.page, paging.limit); } #endregion } if (options.single_only) { var single = query.SingleOrDefault(); if (single == null) { return(null); } var singleResult = GetProductionBatchDynamic(single, projection, options); return(new QueryResult <IDictionary <string, object> >() { Single = singleResult }); } var entities = query.ToList(); var list = GetProductionBatchDynamic(entities, projection, options); var result = new QueryResult <IDictionary <string, object> >(); result.List = list; if (options.count_total) { result.Count = totalCount; } return(result); }
public ValidationData ValidateGetProductionBatchs( ClaimsPrincipal principal, ProductionBatchQueryFilter filter, ProductionBatchQuerySort sort, ProductionBatchQueryProjection projection, ProductionBatchQueryPaging paging, ProductionBatchQueryOptions options) { return(new ValidationData()); }
public static IQueryable <ProductionBatch> Sort(this IQueryable <ProductionBatch> query, ProductionBatchQuerySort model) { foreach (var s in model._sortsArr) { var asc = s[0] == 'a'; var fieldName = s.Remove(0, 1); switch (fieldName) { case ProductionBatchQuerySort.CODE: { query = asc ? query.OrderBy(o => o.Code) : query.OrderByDescending(o => o.Code); } break; } } return(query); }
public async Task <IActionResult> Get([FromQuery][QueryObject] ProductionBatchQueryFilter filter, [FromQuery] ProductionBatchQuerySort sort, [FromQuery] ProductionBatchQueryProjection projection, [FromQuery] ProductionBatchQueryPaging paging, [FromQuery] ProductionBatchQueryOptions options) { var validationData = _service.ValidateGetProductionBatchs( User, filter, sort, projection, paging, options); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } var result = await _service.QueryProductionBatchDynamic( projection, options, filter, sort, paging); if (options.single_only && result == null) { return(NotFound(AppResult.NotFound())); } return(Ok(AppResult.Success(result))); }