public IHttpActionResult Search([ModelBinder(typeof(SearchCriteriaBinder))] coreModel.SearchCriteria criteria) { //Scope bound ACL filtration criteria = FilterOrderSearchCriteria(HttpContext.Current.User.Identity.Name, criteria); var retVal = _searchService.Search(criteria); return(Ok(retVal.ToWebModel())); }
private BackupObject GetBackupObject() { var responce = _customerOrderSearchService.Search(new SearchCriteria { Count = int.MaxValue }); var orderIds = responce.CustomerOrders.Select(x => x.Id); const CustomerOrderResponseGroup filter = CustomerOrderResponseGroup.WithAddresses | CustomerOrderResponseGroup.WithItems | CustomerOrderResponseGroup.WithShipments | CustomerOrderResponseGroup.WithInPayments; return(new BackupObject { CustomerOrders = orderIds.Select(id => _customerOrderService.GetById(id, filter)).ToArray(), }); }
public IHttpActionResult GetNewOrders(string action, string start_date, string end_date, int page) { if (action == "export") { var shipstationOrders = new Orders(); var searchCriteria = new SearchCriteria { ResponseGroup = ResponseGroup.Full }; if (start_date != null) { searchCriteria.StartDate = DateTime.Parse(start_date, new CultureInfo("en-US")); } if (end_date != null) { searchCriteria.EndDate = DateTime.Parse(end_date, new CultureInfo("en-US")); } //if page more than 1 shipstation requests second or later page to be returned. move start position to that page. if (page > 1) { searchCriteria.Start += searchCriteria.Count * (page - 1); } var searchResult = _orderSearchService.Search(searchCriteria); if (searchResult.CustomerOrders != null && searchResult.CustomerOrders.Any()) { var shipstationOrdersList = new List <OrdersOrder>(); searchResult.CustomerOrders.ForEach(cu => shipstationOrdersList.Add(cu.ToShipstationOrder())); shipstationOrders.Order = shipstationOrdersList.ToArray(); //if first page was requested and total orders more than returned add to response overall pages count that shipstation should request. if ((page == 1) && searchResult.TotalCount > searchCriteria.Count) { shipstationOrders.pages = (short)(searchResult.TotalCount / searchCriteria.Count); shipstationOrders.pages += (short)(searchResult.TotalCount % searchCriteria.Count == 0 ? 0 : 1); shipstationOrders.pagesSpecified = true; } } return(Ok(shipstationOrders)); } return(BadRequest()); }
private BackupObject GetBackupObject(Action <ExportImportProgressInfo> progressCallback) { var retVal = new BackupObject(); var progressInfo = new ExportImportProgressInfo(); const CustomerOrderResponseGroup responseGroup = CustomerOrderResponseGroup.WithAddresses | CustomerOrderResponseGroup.WithItems | CustomerOrderResponseGroup.WithShipments | CustomerOrderResponseGroup.WithInPayments; var searchResponse = _customerOrderSearchService.Search(new SearchCriteria { Count = int.MaxValue }); progressInfo.Description = String.Format("{0} orders loading", searchResponse.CustomerOrders.Count()); progressCallback(progressInfo); retVal.CustomerOrders = searchResponse.CustomerOrders.Select((x) => _customerOrderService.GetById(x.Id, responseGroup)).ToList(); return(retVal); }
public IHttpActionResult Search([ModelBinder(typeof(SearchCriteriaBinder))] coreModel.SearchCriteria criteria) { var retVal = _searchService.Search(criteria); return(Ok(retVal.ToWebModel())); }
public IEnumerable <CustomerOrder> GetNewOrders() { return(_orderService.Search(new SearchCriteria()).CustomerOrders.OrderByDescending(o => o.CreatedDate)); }