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. This is very interesting, You are an overly
    professional blogger. I have joined your rss feed and look ahead to seeking extra of
    your fantastic post. Also, I have shared your web
    site in my social networks

  2. With havin so much written content do you ever run into any problems of plagorism or copyright violation? My website has
    a lot of exclusive content I’ve either created myself or outsourced but it appears a lot
    of it is popping it up all over the web without my agreement.
    Do you know any ways to help stop content from being stolen? I’d really appreciate it.

  3. hello!,I love your writing very a lot! percentage we keep up a correspondence more approximately your article
    on AOL? I need a specialist in this space to unravel my problem.
    May be that is you! Looking ahead to look you.

  4. Pingback: Buy Meth Online
  5. Hello, I think your blog might be having browser compatibility issues.

    When I look at your website in Safari, it looks fine but when opening
    in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up!
    Other then that, superb blog!

  6. Hi, I do think this is an excellent site. I stumbledupon it 😉 I may come back yet again since I saved as a favorite it. Money and freedom is the greatest way to change, may you be rich and continue to help others.

  7. Pingback: اغاني
  8. I do not even understand how I stopped up right here, but I believed
    this put up used to be great. I don’t realize who you’re however definitely
    you’re going to a famous blogger should you aren’t already.
    Cheers!

  9. Pingback: Venice photography
  10. Hello just wanted to give you a quick heads up.
    The words in your post seem to be running off the screen in Firefox.
    I’m not sure if this is a format issue or something to do with web browser
    compatibility but I thought I’d post to let you know. The style and design look great though!

    Hope you get the problem solved soon. Kudos

  11. Pingback: CANADA PR POINTS
  12. Pingback: Employee benefits
  13. Hello there! Quick question that’s totally off topic.
    Do you know how to make your site mobile friendly? My web
    site looks weird when viewing from my iphone4. I’m trying to find a
    theme or plugin that might be able to correct this problem.
    If you have any suggestions, please share. Thank you!

  14. I am really impressed with your writing skills as well as with the layout
    on your weblog. Is this a paid theme or did you customize it yourself?
    Either way keep up the nice quality writing, it is
    rare to see a great blog like this one nowadays.

  15. Hey there would you mind sharing which blog platform
    you’re using? I’m planning to start my own blog
    soon but I’m having a hard time selecting between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design and
    style seems different then most blogs and I’m looking
    for something completely unique. P.S Apologies
    for being off-topic but I had to ask!

  16. Hey! I know this is somewhat off topic but I was wondering if you knew where I could find a captcha plugin for my
    comment form? I’m using the same blog platform as yours and
    I’m having difficulty finding one? Thanks a lot!

  17. Excellent article. Keep posting such kind of info on your blog.
    Im really impressed by your site.
    Hi there, You’ve done an excellent job.
    I will certainly digg it and in my view suggest to my friends.

    I’m sure they’ll be benefited from this website.

Leave a Reply

Your email address will not be published.