namespace Simulator.DataStore.Stores { using Simulator.DataObjects; using System; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; public class TripPointStore : BaseStore//, IBaseStore { public TripPointStore(IHttpClientFactory clientFactory, string EndPoint) : base(clientFactory) { base.InitializeStore(EndPoint); } public async Task GetItemAsync(string id) { //Deviating implemetnation because of complxity of the nested API TripPoint tripPoint = null; HttpResponseMessage response = await Client.GetAsync($"/api/trips/{id}/trippoints/{id}"); if (response.IsSuccessStatusCode) { response.Content.Headers.ContentType.MediaType = "application/json"; tripPoint = await response.Content.ReadAsAsync(); } return tripPoint; } public async Task GetItemAsync(TripPoint item) { //Deviating implemetnation because of complxity of the nested API TripPoint tripPoint = null; HttpResponseMessage response = await Client.GetAsync($"/api/trips/{item.TripId}/trippoints/{item.Id}"); if (response.IsSuccessStatusCode) { response.Content.Headers.ContentType.MediaType = "application/json"; tripPoint = await response.Content.ReadAsAsync(); } return tripPoint; } public Task> GetItemsAsync() { throw new NotImplementedException(); } public async Task> GetItemsAsync(Trip item) { List tripPoints = null; HttpResponseMessage response = await Client.GetAsync($"api/trips/{item.Id}/trippoints"); if (response.IsSuccessStatusCode) { response.Content.Headers.ContentType.MediaType = "application/json"; tripPoints = await response.Content.ReadAsAsync>(); } return tripPoints; } public async Task CreateItemAsync(TripPoint item) { string apiPath = $"api/trips/{item.TripId.ToString()}/trippoints"; HttpResponseMessage response = await Client.PostAsJsonAsync(apiPath, item); response.EnsureSuccessStatusCode(); response.Content.Headers.ContentType.MediaType = "application/json"; item = await response.Content.ReadAsAsync(); return item; } public Task UpdateItemAsync(TripPoint item) { throw new NotImplementedException(); } public Task DeleteItemAsync(TripPoint item) { throw new NotImplementedException(); } } }