Dashboard Page - Appointments:
- create separate dashboard components for doctor and patient - add appointments to dashboard components - add code to backend for appointments retrieval
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
using HealthcareManagerUiWebAssem.Models;
|
||||
using HealthcareManagerUiWebAssem.Services.Http;
|
||||
|
||||
namespace HealthcareManagerUiWebAssem.Services.Appointment;
|
||||
|
||||
public class AppointmentService : IAppointmentService
|
||||
{
|
||||
private readonly IRequestHttpService _requestHttpService;
|
||||
|
||||
public AppointmentService(IRequestHttpService requestHttpService)
|
||||
{
|
||||
_requestHttpService = requestHttpService;
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> GetAppointmentsByPatient(Guid patientId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _requestHttpService.GetByIdAsync("/Appointments/patient", patientId);
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.InternalServerError,
|
||||
Data = null,
|
||||
Message = ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> GetAppointmentsByDoctor(Guid doctorId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _requestHttpService.GetByIdAsync("/Appointments/doctor", doctorId);
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.InternalServerError,
|
||||
Data = null,
|
||||
Message = ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task<BaseResponse> CreateAppointment(
|
||||
AppointmentManagementModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _requestHttpService.PostAsync("/Appointments", model);
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.InternalServerError,
|
||||
Data = null,
|
||||
Message = ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> DeleteAppointment(AppointmentManagementModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _requestHttpService.DeleteByFilterAsync("/Appointments", model);
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.InternalServerError,
|
||||
Data = null,
|
||||
Message = ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using HealthcareManagerUiWebAssem.Models;
|
||||
|
||||
namespace HealthcareManagerUiWebAssem.Services.Appointment;
|
||||
|
||||
public interface IAppointmentService
|
||||
{
|
||||
Task<BaseResponse> GetAppointmentsByPatient(Guid patientId);
|
||||
|
||||
Task<BaseResponse> GetAppointmentsByDoctor(Guid doctorId);
|
||||
|
||||
Task<BaseResponse> CreateAppointment(AppointmentManagementModel model);
|
||||
|
||||
Task<BaseResponse> DeleteAppointment(AppointmentManagementModel model);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class AuthenticationService : IAuthenticationService
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _requestHttpService.PostAsync("/Doctors/register", userRegistrationModel);
|
||||
var response = await _requestHttpService.PostAsync("/Patients/register", userRegistrationModel);
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -12,4 +12,6 @@ public interface IRequestHttpService
|
||||
Task<BaseResponse> PutAsync(string uri, object data, IDictionary<string, string> headers = null);
|
||||
|
||||
Task<BaseResponse> DeleteAsync(string uri, Guid id, IDictionary<string, string> headers = null);
|
||||
|
||||
Task<BaseResponse> DeleteByFilterAsync(string uri, object data, IDictionary<string, string> headers = null);
|
||||
}
|
||||
@@ -79,6 +79,18 @@ public class RequestHttpService : IRequestHttpService
|
||||
Thread.Sleep(1000);
|
||||
return await HandleResponse(response, uri);
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> DeleteByFilterAsync(string uri, object data, IDictionary<string, string>? headers = null)
|
||||
{
|
||||
headers ??= new Dictionary<string, string>();
|
||||
var request = new HttpRequestMessage(HttpMethod.Delete, $"{_apiEndpoint}{uri}");
|
||||
AddHeaders(request, headers);
|
||||
request.Content = new StringContent(JsonSerializer.Serialize(data), Encoding.UTF8, "application/json");
|
||||
|
||||
var response = await _httpClient.SendAsync(request);
|
||||
Thread.Sleep(1000);
|
||||
return await HandleResponse(response, uri);
|
||||
}
|
||||
|
||||
private async void AddHeaders(HttpRequestMessage request, IDictionary<string, string>? headers)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user