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: best cock rings
  2. Pingback: en iyi yatırım
  3. Pingback: online slots
  4. Pingback: kamudan haberler
  5. Pingback: online casinos usa
  6. Pingback: en iyi yatırım
  7. Pingback: gambling games
  8. Pingback: slot games
  9. Pingback: online casino usa
  10. Pingback: Reformhaus
  11. Pingback: hollywood casino
  12. Pingback: buy followers
  13. Pingback: usa pharmacy
  14. Pingback: Tenuate retard
  15. Pingback: canada pharmacy
  16. Pingback: thc vape juice
  17. Pingback: o-dsmt
  18. Pingback: Fish scale coke
  19. Pingback: Change DMT
  20. Pingback: College kenya
  21. Pingback: liquid k2 for sale
  22. Pingback: sr22 insurance
  23. Pingback: canadian pharmacy
  24. Pingback: brazzers
  25. Pingback: film

Leave a Reply

Your email address will not be published.