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

445 Replies to “Xamabrouk.RestHelper”

  1. Pingback: film
  2. Pingback: Gold jewelry set
  3. Pingback: speedy cash
  4. Pingback: backlink
  5. Pingback: cbd oil florida
  6. Pingback: cialis online
  7. Pingback: pubg mobile hile
  8. Pingback: bitcoin trading
  9. Pingback: cbd oil for pain
  10. Pingback: cbd hemp oil
  11. Pingback: buy custom essay
  12. Pingback: MAERSK LINE
  13. Pingback: fake essay writer
  14. Pingback: buy bitcoin canada
  15. Pingback: buy essays papers
  16. Pingback: french homework
  17. Pingback: help my essay
  18. Pingback: sphynx kittens
  19. Pingback: cockatoos
  20. Pingback: toucan tongue

Leave a Reply

Your email address will not be published.