In Vendr v2 the old SearchOrders method was removed (it has been deprecated for a few versions) in favour of our new SearchOrders method that takes a query specification. The specification pattern gives much more flexibility over what you want to search whilst at the same time ensuring searching adheres to a strict API.
An example of using the newer specification pattern would look something like this
public class MyController
{
private readonly IOrderService _orderService;
public MyController(IOrderService _orderService)
{
_orderService = _orderService;
}
public void MyMethod()
{
var results = _orderService.SearchOrders(
(where) => where.FromStore(storeId)
.And(where.IsFinalized())
.And(where.HasPaymentStatus(PaymentStatus.Authorized)),
(sort) => sort.ByFinalizeDate(Sort.Descending)
.Then(sort.ByPaymentStatusName()),
1, 10);
}
}
As you can see, the SearchOrders method accepts a couple of lambda functions which allow you to build up your query from our allowed specifications.
In your example where it looks like you are just getting finalized orders for a given store, it would be something like
public void MyMethod()
{
var results = _orderService.SearchOrders(
(where) => where.FromStore(storeId)
.And(where.IsFinalized()),
1, long.MaxValue);
}
SearchOrders() no longer working after upgrade
Morning,
After our recent upgrade from 1.8.6 to 2.1 some reports that we had set up have stopped working.
I've managed to work throw the majority of issues, but I can't seem to resolve one with orderService/SearchOrders -
SearchOrders does not have a parameter named StoreId is the message.
But from reading the docs on Vendr site, it does ?
TIA
Hey George,
In Vendr v2 the old
SearchOrders
method was removed (it has been deprecated for a few versions) in favour of our newSearchOrders
method that takes a query specification. The specification pattern gives much more flexibility over what you want to search whilst at the same time ensuring searching adheres to a strict API.An example of using the newer specification pattern would look something like this
As you can see, the
SearchOrders
method accepts a couple of lambda functions which allow you to build up your query from our allowed specifications.In your example where it looks like you are just getting finalized orders for a given store, it would be something like
Hope this helps
Matt
Sorry for the delay in getting back to you Matt!
Got it!
Works a treat.
Thank you, as always, for your time and support!
Cheers,
George
is working on a reply...