Copied to clipboard

Flag this post as spam?

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


  • Peter Rombouts 71 posts 265 karma points
    Jun 03, 2013 @ 17:09
    Peter Rombouts
    0

    How to instantiate OrderService

    Hi all,

    I'm trying to write code to get some orders.
    I want to use the OrderService class like this:

    TeaCommerce.Api.Services.OrderService ios = new TeaCommerce.Api.Services.OrderService(iorcs);
    

    The problem is, the constructor takes to params, and I haven't found out how to create an OrderRepository.

    Can anyone help me out here?

    Thanks in advance.
    Peter

    FYI
    The constructor also needs some cacheservice, which I think I should instantiate like next code, but as you can see, I'm having trouble with the IOrderRepository, and cannot find anything in the DLLs:

    TeaCommerce.Api.Infrastructure.Caching.CacheService cs = new Api.Infrastructure.Caching.CacheService();
                TeaCommerce.Api.Repositories.OrderRepository ior = *something here...*
  • Peter Rombouts 71 posts 265 karma points
    Jun 04, 2013 @ 11:18
    Peter Rombouts
    100

    Solved it myself:

    When adding the Autofac (https://code.google.com/p/autofac/wiki/GettingStarted#Add_Autofac_References) package, I was able to resolve the repository and do queries on the orders!

    DependencyContainer.Instance.Resolve<IOrderRepository>().Search(storeIdorderStatusIdorderNumberfirstNamelastNamepaymentStatestartDateendDateisFinalizedpageitemsPerPage);
    
  • Anders Burla 2560 posts 8256 karma points
    Jun 05, 2013 @ 17:19
    Anders Burla
    0

    Hi Peter

    The simple way is:

    OrderService.Instance.TheMethodYouWantToInvoke()

    All the Autofac is hidden, AND if someone did a DependencySuppress of the OrderService then your code wouldn't use it. But the singleton way ensures you that you get the one that is registered and you dont have to think about Autofac and other advanced stuff :)

    Kind regards
    Anders

  • Peter Rombouts 71 posts 265 karma points
    Jun 05, 2013 @ 17:32
    Peter Rombouts
    0

    Ah ok thanks, my namespaces conflicted I think, that is why I couldn't normally find the OrderService...

    Any idea on when the .Net documentation will be online?

  • Anders Burla 2560 posts 8256 karma points
    Jun 05, 2013 @ 17:56
    Anders Burla
    0

    Ahh that might be the problem :)

    Not have an exact date for it - but we are working on it. Would you need some examples or just a normal .Net API reference document with all classes, namespaces and methods?

    Kind regards
    Anders

  • Peter Rombouts 71 posts 265 karma points
    Jun 05, 2013 @ 18:38
    Peter Rombouts
    0

    Well any basic API reference would be nice:
    Most methods like this OrderService.Instance.Search are trivial for any custom software building, so any docs would be appreciated!

    My conflicting REST service namespace OrderService obviously masked the one I needed...
    Which is resolved now by refactoring my namespaces and REST services.

    Kind regards,
    Peter Rombouts

Please Sign in or register to post replies

Write your reply to:

Draft