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: lasix 100 mg cost
  2. Pingback: small dildo
  3. Pingback: silver bullet toy
  4. Pingback: find a builder
  5. Pingback: dinh cu canada
  6. Pingback: cheap abilify 15mg
  7. Pingback: actos 30mg prices
  8. Pingback: ucuz uçak bileti
  9. Pingback: hat macca
  10. Pingback: sua hat macca
  11. Pingback: antivert 25mg usa
  12. Pingback: buy arava 10 mg
  13. Pingback: tapchiphunuvn
  14. Pingback: beginner sex toys
  15. Pingback: blogcaodep.com
  16. Pingback: tabakvervanger
  17. Pingback: cell phone
  18. Pingback: wasmachine monteur
  19. Pingback: atarax 25 mg pills
  20. Pingback: mahna mahna song
  21. Pingback: greengo

Leave a Reply

Your email address will not be published.