Creating the Stocklist web service controller

Let's build our client web service controller to access the API. Since we built the back end, we should be able to whip this up very quickly. Our first step is to create the object which will deserialize a StockItem. We refer to these as contracts. Add a new folder in your Stocklist.Portable project called StocklistWebServiceController, and add another folder in this called Contracts. Create a new file called StockItemContract.cs and implement the following:

public sealed class StockItemContract 
    { 
        #region Public Properties 
 
        public int Id { get; set;} 
 
        public string Name { get; set; } 
 
        public string Category { get; set; } 
 
        public decimal Price { get; set; } 
 
        #endregion 
    } 

Now let's go ahead and build the ...

Get Xamarin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.