Creating an API Data Service
Using BaseHttpService as a foundation that abstracts away the HTTP request details, we can now begin to create services that leverage it to get responses back from the API in the form of domain-specific models. Specifically, we will create a data service that can be used by the ViewModels to get the TripLogEntry objects from the backend service.
We will start off by defining an interface for the data service that can be injected into the ViewModels, ensuring there is no strict dependency on the API or the logic that communicates with it, continuing the pattern we put in place in Chapter 4, Platform Specific Services and Dependency Injection.
Create a new interface named
ITripLogDataServicein theServicesfolder in the core library:public interface ITripLogDataService { }Update the
ITripLogDataServiceinterface with methods to get, update, and deleteTripLogEntryobjects:public interface ITripLogDataService { Task<IList<TripLogEntry>> GetEntriesAsync...