public ERPQuery(IPlatformServiceFactory platformServiceFactory) { Field <ListGraphType <OrderType> >("searchOrders", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <SearchOrderInputType> > { Name = "searchOrderInput", Description = "Search Order Input" }), resolve: context => { SearchOrderInput searchOrderInput = context.GetArgument <SearchOrderInput>("searchOrderInput"); return(platformServiceFactory.GetOrderService(searchOrderInput.Company).SearchOrders(searchOrderInput.SearchType, searchOrderInput.SearchText)); } ); Field <ListGraphType <OrderSummaryType> >("orderSummary", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "company", Description = "Company" }), resolve: context => { string company = context.GetArgument <string>("company"); return(platformServiceFactory.GetOrderService(company).GetOrderSummary()); }); }
public async Task <IActionResult> GetListOfOrders([FromQuery] SearchOrderInput searchInput) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var orders = await ordersService.FindClosestOrdersAsync(searchInput); var ordersVM = mapper.Map <IEnumerable <ClosestOrderVM> >(orders); return(Ok(ordersVM)); }
public async Task <IEnumerable <ClosestOrderDTO> > FindClosestOrdersAsync(SearchOrderInput searchInput) { var searchDTO = mapper.Map <DALSearchOrderDTO>(searchInput); return(await ordersRepository.FindClosestOrdersAsync(searchDTO)); }
public SearchOrderOutput Search(SearchOrderInput input) { using (var dbContext = new AllureContext()) { IQueryable <Order> query = dbContext .Set <Order>() .Include(o => o.Details) .Include(o => o.Customer); if (input.Id.HasValue) { query = query.Where(o => o.Id == input.Id); } if (input.Status.HasValue) { query = query.Where(o => o.Status == input.Status.Value); } if (input.MinTotalPrice.HasValue) { query = query.Where(o => o.OriginalRealCharge >= input.MinTotalPrice.Value); } if (input.MaxTotalPrice.HasValue) { query = query.Where(o => o.OriginalRealCharge <= input.MaxTotalPrice.Value); } if (!input.CustomerName.IsNullOrEmpty()) { query = query.Where(o => o.Customer.FirstName.Contains(input.CustomerName) || o.Customer.LastName.Contains(input.CustomerName)); } if (input.MinCreateTime.HasValue) { query = query.Where(o => o.CreateTime >= input.MinCreateTime.Value); } if (input.MaxCreateTime.HasValue) { query = query.Where(o => o.CreateTime <= input.MaxCreateTime.Value); } if (input.MinUpdateTime.HasValue) { query = query.Where(o => o.UpdateTime >= input.MinUpdateTime.Value); } if (input.MaxUpdateTime.HasValue) { query = query.Where(o => o.UpdateTime <= input.MaxUpdateTime.Value); } var result = new SearchOrderOutput(); result.Count = query.Count(); var pageSize = input.PageSize.GetValueOrDefault(10); var pageNumber = input.PageNumber.GetValueOrDefault(1) - 1; result.Orders = query .OrderBy(o => o.Id) .Skip(pageNumber * pageSize) .Take(pageSize) .ToArray() .Select(o => new OrderOutput(o)) .ToArray(); return(result); } }