Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • George Logan 36 posts 168 karma points
    Mar 21, 2022 @ 11:41
    George Logan
    0

    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 - enter image description here

    SearchOrders does not have a parameter named StoreId is the message.

    But from reading the docs on Vendr site, it does ?

    TIA

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Mar 21, 2022 @ 13:45
    Matt Brailsford
    100

    Hey George,

    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);
    }
    

    Hope this helps

    Matt

  • George Logan 36 posts 168 karma points
    Mar 22, 2022 @ 14:17
    George Logan
    1

    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

Please Sign in or register to post replies

Write your reply to:

Draft