Xamabrouk.RestHelper

Provides a full and clean solution to POST, GET,PUT or DELETE data to server using a Rest API..

Introduction

Most of developer are using Web APIs when creating Mobile, Desktop or Web Apps. Every Web API provides a nuber of methodes to be called in the client side : POST, GET, PUT, DELETE.

In oder to help developers to implement a simple an clean client code, i wrote my Nuget Package https://www.nuget.org/packages/Xamabrouk.RestHelper/.

Let’s start coding !

In order to test and discover the functionalities of our Package we will use the public Rest API :
https://www.predic8.de/rest-api-public-sample.htm . You can find more details in the Swagger-UI.

First of all, install the Nuget Package in your project.

We will use the Customer API witch returns a json result in this form :

{
  "meta": {
    "count": 22,
    "limit": 10,
    "page": 2,
    "previous_url": "/shop/products/?page=1&limit=10",
    "next_url": "/shop/products/?page=3&limit=10"
  },
  "customers": [
    {
      "firstname": "Susan",
      "lastname": "Tanner",
      "customer_url": "/shop/customer/642"
    }
  ]
}

We need now to create our ViewModel :

Note : Your Model should implement the IXMModel interface.

 public class Customer : IXMModel<long>

Now for the service you just need to inherit from the
XMBaseDataService and set your Model in the generic type and the type of the id of your Model.

public class CustomersService : XMBaseDataService<Customer, long>

In our example it’s like :

It’s too easy now to load data, just call :

CustomersService customersService = new CustomersService();
var customers = customersService.GetAllItems<VMCustomer>();

You can also use async methodes like :

var customers = await customersService.GetAllItemsAsync<VMCustomer>();

Note : All methodes can be called asynchronous and also can be overridden!

See the simple project here and enjoy! : https://github.com/MabroukENG/XM.RestHelper.Simple.

0Shares

178 Replies to “Xamabrouk.RestHelper”

  1. Hi there are using WordPress for your blog platform?
    I’m new to the blog world but I’m trying to get started and
    create my own. Do you need any coding expertise to
    make your own blog? Any help would be greatly appreciated!

  2. Usually I do not read post on blogs, but I wish to say that
    this write-up very compelled me to check out and do it!
    Your writing taste has been surprised me. Thanks, very nice article.

  3. After checking out a number of the blog posts on your web site,
    I seriously appreciate your technique of blogging.

    I saved as a favorite it to my bookmark site list and will be checking back in the near
    future. Please check out my website as well and tell me your opinion.

  4. Whats up are using WordPress for your blog platform?
    I’m new to the blog world but I’m trying to get started and create my own. Do you need any html coding expertise to make your
    own blog? Any help would be really appreciated!

  5. After checking out a number of the blog articles on your site, I really appreciate your technique
    of blogging. I added it to my bookmark webpage list and will be checking back in the near future.

    Take a look at my website as well and tell me what you think.

  6. Pingback: Google
  7. I do trust all of the ideas you have presented on your post.

    They’re really convincing and will certainly work.
    Still, the posts are too brief for starters.
    May just you please prolong them a bit from next time?
    Thank you for the post.

  8. When I initially commented I clicked the “Notify me when new comments are added” checkbox and
    now each time a comment is added I get four emails
    with the same comment. Is there any way you can remove people from that service?
    Thanks!

  9. Can I just say what a comfort to find an individual who genuinely knows what they’re talking about on the net.
    You definitely understand how to bring an issue to
    light and make it important. More people ought to
    check this out and understand this side of the story.
    I was surprised that you aren’t more popular since
    you certainly possess the gift.

  10. Pingback: Online Impacts
  11. Hello there, just became aware of your blog through Google, and found that it
    is really informative. I am going to watch out
    for brussels. I’ll appreciate if you continue this in future.
    Lots of people will be benefited from your writing. Cheers!

  12. Hello my family member! I want to say that this article is
    awesome, great written and come with almost all vital infos.
    I’d like to see more posts like this .

  13. Pingback: Google
  14. I’ve been exploring for a bit for any high
    quality articles or blog posts on this sort of space .
    Exploring in Yahoo I eventually stumbled upon this website.

    Reading this info So i am satisfied to show that I have
    an incredibly excellent uncanny feeling I discovered just what I
    needed. I most indubitably will make sure to do not
    put out of your mind this website and provides
    it a glance on a relentless basis.

  15. Pingback: affiliate link
  16. Pingback: Cannabis THC Oil
  17. Pingback: Escort amsterdam
  18. Pingback: gaming
  19. Pingback: Keynote Speaker
  20. Hey there are using WordPress for your blog platform? I’m new to the blog world but I’m trying to get started and set up my own. Do you
    require any coding knowledge to make your own blog? Any help would be greatly appreciated!

  21. What’s up i am kavin, its my first occasion to commenting
    anyplace, when i read this paragraph i thought i could also create comment due to this sensible paragraph.

  22. Having read this I believed it was extremely enlightening.
    I appreciate you finding the time and energy to put this
    information together. I once again find myself personally spending way too
    much time both reading and leaving comments. But
    so what, it was still worthwhile!

  23. I don’t even know how I ended up here, but I thought this post was good.
    I do not know who you are but certainly you are going to
    a famous blogger if you are not already 😉 Cheers!

  24. I have been surfing online more than 2 hours today, yet I never found any interesting article like yours.
    It’s pretty worth enough for me. Personally, if all web owners and bloggers made good content as you did,
    the web will be much more useful than ever before.

  25. I don’t know whether it’s just me or if perhaps everyone else encountering
    problems with your site. It appears like some of the text in your
    content are running off the screen. Can somebody else please provide feedback and
    let me know if this is happening to them as well?
    This may be a issue with my internet browser because I’ve
    had this happen before. Thanks

  26. Hello there, just became alert to your blog through Google, and
    found that it is really informative. I am going
    to watch out for brussels. I will appreciate if you continue this in future.
    Many people will be benefited from your writing.
    Cheers!

Leave a Reply

Your email address will not be published.