first commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using BethanysPieShopHRM.Shared.Domain;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace Webshop.App.Services
|
||||
{
|
||||
public class CountryDataService : ICountryDataService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
public CountryDataService(
|
||||
HttpClient httpClient)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Country>> GetCountries() {
|
||||
return await _httpClient.GetFromJsonAsync<IEnumerable<Country>>("/api/country");
|
||||
}
|
||||
public async Task<Country> GetCountryById(int countryId)
|
||||
{
|
||||
return await _httpClient.GetFromJsonAsync<Country>($"/api/country/{countryId}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using BethanysPieShopHRM.Shared.Domain;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace Webshop.App.Services
|
||||
{
|
||||
public class EmployeeDataService : IEmployeeDataService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
public EmployeeDataService(
|
||||
HttpClient httpClient)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
public async Task<Employee?> AddEmployee(Employee employee)
|
||||
{
|
||||
var response = await _httpClient.PostAsJsonAsync<Employee>("/api/employee", employee);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return await response.Content.ReadFromJsonAsync<Employee>();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task DeleteEmployee(int EmployeeId)
|
||||
{
|
||||
await _httpClient.DeleteAsync($"/api/employee/{EmployeeId}");
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Employee>> GetAllEmployees()
|
||||
{
|
||||
return await _httpClient.GetFromJsonAsync<IEnumerable<Employee>>("/api/employee");
|
||||
}
|
||||
|
||||
public async Task<Employee> GetEmployeeDetails(int employeeId)
|
||||
{
|
||||
return await _httpClient.GetFromJsonAsync<Employee>($"api/employee/{employeeId}");
|
||||
}
|
||||
|
||||
public async Task UpdateEmployee(Employee employee)
|
||||
{
|
||||
await _httpClient.PutAsJsonAsync<Employee>("/api/employee", employee);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using BethanysPieShopHRM.Shared.Domain;
|
||||
|
||||
namespace Webshop.App.Services
|
||||
{
|
||||
public interface ICountryDataService
|
||||
{
|
||||
public Task<IEnumerable<Country>> GetCountries();
|
||||
public Task<Country> GetCountryById(int countryId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using BethanysPieShopHRM.Shared.Domain;
|
||||
|
||||
namespace Webshop.App.Services
|
||||
{
|
||||
public interface IEmployeeDataService
|
||||
{
|
||||
Task<IEnumerable<Employee>> GetAllEmployees();
|
||||
Task<Employee> GetEmployeeDetails(int employeeId);
|
||||
Task<Employee?> AddEmployee(Employee employee);
|
||||
Task UpdateEmployee(Employee employee);
|
||||
Task DeleteEmployee(int EmployeeId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using BethanysPieShopHRM.Shared.Domain;
|
||||
|
||||
namespace Webshop.App.Services
|
||||
{
|
||||
public interface IJobCategoryDataService
|
||||
{
|
||||
public Task<IEnumerable<JobCategory>> GetJobCategories();
|
||||
public Task<JobCategory> GetJobCategoryById(int jobCategoryId);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using BethanysPieShopHRM.Shared.Domain;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace Webshop.App.Services
|
||||
{
|
||||
public class JobCategoryDataService : IJobCategoryDataService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
public JobCategoryDataService(
|
||||
HttpClient httpClient)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<JobCategory>> GetJobCategories()
|
||||
{
|
||||
return await _httpClient.GetFromJsonAsync<IEnumerable<JobCategory>>("/api/jobcategory");
|
||||
}
|
||||
|
||||
public async Task<JobCategory> GetJobCategoryById(int jobCategoryId)
|
||||
{
|
||||
return await _httpClient.GetFromJsonAsync<JobCategory>($"/api/jobcategory/{jobCategoryId}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user