38 lines
1.5 KiB
C#
38 lines
1.5 KiB
C#
using System.Net.Http.Json;
|
|
using System.Text.Json;
|
|
using HealthcareManagerUiWebAssem.Entities;
|
|
using HealthcareManagerUiWebAssem.Models;
|
|
using HealthcareManagerUiWebAssem.Services.RequestHttp;
|
|
|
|
namespace HealthcareManagerUiWebAssem.Services.AdminUserManagement;
|
|
|
|
public class AdminManagementService(IRequestHttpService requestHttpService) : IAdminManagementService
|
|
{
|
|
public async Task<ApiResponse<List<Doctor>>> GetDoctors()
|
|
{
|
|
var response = await requestHttpService.GetAsync("/api/Doctors");
|
|
var responseContent = await response.Content.ReadAsStringAsync();
|
|
return JsonSerializer.Deserialize<ApiResponse<List<Doctor>>>(responseContent,
|
|
new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
|
}
|
|
|
|
public async Task<ApiResponse<List<Patient>>> GetPatients()
|
|
{
|
|
var response = await requestHttpService.GetAsync("/api/Patients");
|
|
var responseContent = await response.Content.ReadAsStringAsync();
|
|
return JsonSerializer.Deserialize<ApiResponse<List<Patient>>>(responseContent,
|
|
new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
|
}
|
|
|
|
public async Task<bool> DeleteDoctor(Guid id)
|
|
{
|
|
var response = await requestHttpService.DeleteAsync($"/api/Doctors/{id}");
|
|
return response.IsSuccessStatusCode;
|
|
}
|
|
|
|
public async Task<bool> DeletePatient(Guid id)
|
|
{
|
|
var response = await requestHttpService.DeleteAsync($"/api/Patients/{id}");
|
|
return response.IsSuccessStatusCode;
|
|
}
|
|
} |