Adding a Blazor WASM app

This commit is contained in:
2026-03-22 01:10:14 +01:00
parent ce04cd8d77
commit c86c989cb5
81 changed files with 87512 additions and 2 deletions
+46
View File
@@ -0,0 +1,46 @@
using CityInfo.WEB.Models;
using System.Net.Http.Json;
namespace CityInfo.WEB.Services
{
public class CityDataService : ICityDataService
{
private readonly HttpClient _httpClient;
public CityDataService(
HttpClient httpClient)
{
_httpClient = httpClient;
}
public async Task<City> CreateCity(City city)
{
var response = await _httpClient.PostAsJsonAsync<City>("/api/cities", city);
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadFromJsonAsync<City>();
}
return null;
}
public async Task DeleteCity(int cityId)
{
await _httpClient.DeleteAsync($"/api/cities/{cityId}");
}
public async Task<IEnumerable<City>> GetCities()
{
return await _httpClient.GetFromJsonAsync<IEnumerable<City>>("/api/cities");
}
public async Task<City> GetCity(int cityId)
{
return await _httpClient.GetFromJsonAsync<City>($"/api/cities/{cityId}");
}
public async Task UpdateCity(City city)
{
await _httpClient.PutAsJsonAsync<City>($"/api/cities/{city.Id}", city);
}
}
}
+13
View File
@@ -0,0 +1,13 @@
using CityInfo.WEB.Models;
namespace CityInfo.WEB.Services
{
public interface ICityDataService
{
public Task<IEnumerable<City>> GetCities();
public Task<City> GetCity(int cityId);
public Task<City> CreateCity(City city);
public Task UpdateCity(City city);
public Task DeleteCity(int cityId);
}
}
@@ -0,0 +1,13 @@
using CityInfo.WEB.Models;
namespace CityInfo.WEB.Services
{
public interface IPointOfInterestDataService
{
public Task<IEnumerable<PointOfInterest>> GetPointsOfInterest(int cityId);
public Task<PointOfInterest> GetPointOfInterest(int cityId, int pointOfInterestId);
public Task<PointOfInterest> CreatePointOfInterest(int cityId, PointOfInterest pointOfInterest);
public Task UpdatePointOfInterest(int cityId, PointOfInterest pointOfInterest);
public Task DeletePointOfInterest(int cityId, int pointOfInterestId);
}
}
@@ -0,0 +1,39 @@
using CityInfo.WEB.Models;
namespace CityInfo.WEB.Services
{
public class PointOfInterestDataService : IPointOfInterestDataService
{
private readonly HttpClient _httpClient;
public PointOfInterestDataService(
HttpClient httpClient)
{
_httpClient = httpClient;
}
public Task<PointOfInterest> CreatePointOfInterest(int cityId, PointOfInterest pointOfInterest)
{
throw new NotImplementedException();
}
public Task DeletePointOfInterest(int cityId, int pointOfInterestId)
{
throw new NotImplementedException();
}
public Task<PointOfInterest> GetPointOfInterest(int cityId, int pointOfInterestId)
{
throw new NotImplementedException();
}
public Task<IEnumerable<PointOfInterest>> GetPointsOfInterest(int cityId)
{
throw new NotImplementedException();
}
public Task UpdatePointOfInterest(int cityId, PointOfInterest pointOfInterest)
{
throw new NotImplementedException();
}
}
}