Building an API controller

Web API controllers are used to handle web requests. 99% of the time, mobile applications will always use an API layer in which it will call web requests to retrieve data, perform login, and so on. For our example, we are going to add a new empty WEBAPI 2 controller.

Building an API controller

Implement the following:

public class StockItemsController : ApiController { List<StockItem> StockItems = new List<StockItem>() { new StockItem { Id = 1, Name = "Tomato Soup", Category = "Groceries", Price = 1 }, new StockItem { Id = 2, Name = "Yo-yo", Category = "Toys", Price = 3.75M }, new StockItem { Id = 3, Name = "Hammer", Category = "Hardware", Price = ...

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.