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.
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 = 16.99M } }; public IEnumerable<StockItem> GetAllStockItems() { return StockItems; } public StockItem GetStockItem(int id) { &...