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

211 Replies to “Xamabrouk.RestHelper”

  1. Pingback: tamoxifen for men
  2. Pingback: tamoxifen dosage
  3. Pingback: ivermectin 18mg
  4. Pingback: stromectol generic
  5. Pingback: cost of viagra
  6. Pingback: sildenafil 120
  7. Pingback: prednisone 4mg
  8. Pingback: otc viagra
  9. Pingback: viagra dosage
  10. Pingback: viagra sildenafil
  11. Pingback: buy amoxil
  12. Pingback: ivermectin 18mg
  13. Pingback: lasix furosemide
  14. Pingback: plaquenil 200 mg
  15. Pingback: viagra coupons
  16. Pingback: super avana price
  17. Pingback: provigil 100mg
  18. Pingback: stromectol price
  19. Pingback: ventolin 108 mcg
  20. Pingback: zithromax generics
  21. Pingback: lasix 1975
  22. Pingback: neurontin 400
  23. Pingback: viagra generico

Leave a Reply

Your email address will not be published.