namespace Simulator.DataStore.Stores { using Simulator.DataObjects; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; public class PoiStore : BaseStore, IBaseStore { public PoiStore(string EndPoint) { base.InitializeStore(EndPoint); } public async Task GetItemAsync(string id) { Poi poi = null; HttpResponseMessage response = await Client.GetAsync($"/api/poi/{id}"); if (response.IsSuccessStatusCode) { response.Content.Headers.ContentType.MediaType = "application/json"; poi = await response.Content.ReadAsAsync(); } return poi; } public async Task> GetItemsAsync() { List trips = null; HttpResponseMessage response = await Client.GetAsync("api/poi/"); if (response.IsSuccessStatusCode) { response.Content.Headers.ContentType.MediaType = "application/json"; trips = await response.Content.ReadAsAsync>(); } return trips; } public async Task CreateItemAsync(Poi item) { HttpResponseMessage response = await Client.PostAsJsonAsync("api/poi", item); response.EnsureSuccessStatusCode(); if (response.IsSuccessStatusCode) { response.Content.Headers.ContentType.MediaType = "application/json"; item = await response.Content.ReadAsAsync(); } return item; } public async Task UpdateItemAsync(Poi item) { HttpResponseMessage response = await Client.PatchAsJsonAsync($"api/poi/{item.Id}", item); response.EnsureSuccessStatusCode(); if (response.IsSuccessStatusCode) response.Content.Headers.ContentType.MediaType = "application/json"; return true; } public async Task DeleteItemAsync(Poi item) { HttpResponseMessage response = await Client.DeleteAsync($"api/poi/{item.Id}"); response.EnsureSuccessStatusCode(); if (response.IsSuccessStatusCode) response.Content.Headers.ContentType.MediaType = "application/json"; return true; } } }