migrare UI in WebAssembly + integrare Serviciu stocare info pe web + WebToken
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
using HealthcareManagerUiWebAssem.Models;
|
||||
using HealthcareManagerUiWebAssem.Services.Http;
|
||||
|
||||
namespace HealthcareManagerUiWebAssem.Services.Authentication;
|
||||
|
||||
public class AuthenticationService : IAuthenticationService
|
||||
{
|
||||
private readonly IRequestHttpService _requestHttpService;
|
||||
|
||||
public AuthenticationService(IRequestHttpService requestHttpService)
|
||||
{
|
||||
_requestHttpService = requestHttpService;
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> Login(UserLoginModel userLoginModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _requestHttpService.PostAsync("/Authorization/login", userLoginModel);
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.InternalServerError,
|
||||
Data = null,
|
||||
Message = ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> RegisterDoctor(UserRegisterModel userRegistrationModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _requestHttpService.PostAsync("/Doctors/register", userRegistrationModel);
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.InternalServerError,
|
||||
Data = null,
|
||||
Message = ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> RegisterPatient(UserRegisterModel userRegistrationModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _requestHttpService.PostAsync("/Doctors/register", userRegistrationModel);
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.InternalServerError,
|
||||
Data = null,
|
||||
Message = ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> ResetPassword(UserLoginModel dto)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _requestHttpService.PostAsync("/Authorization/reset_password", dto);
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.InternalServerError,
|
||||
Data = null,
|
||||
Message = ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> RefreshToken(TokenRefreshModel dto)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _requestHttpService.PostAsync("/Authorization/refresh_token", dto);
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.InternalServerError,
|
||||
Data = null,
|
||||
Message = ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using HealthcareManagerUiWebAssem.Models;
|
||||
|
||||
namespace HealthcareManagerUiWebAssem.Services.Authentication;
|
||||
|
||||
public interface IAuthenticationService
|
||||
{
|
||||
Task<BaseResponse> Login(UserLoginModel userLoginModel);
|
||||
Task<BaseResponse> RegisterPatient(UserRegisterModel userRegistrationModel);
|
||||
Task<BaseResponse> RegisterDoctor(UserRegisterModel userRegistrationModel);
|
||||
Task<BaseResponse> ResetPassword(UserLoginModel userResetPasswordModel);
|
||||
Task<BaseResponse> RefreshToken(TokenRefreshModel dto);
|
||||
}
|
||||
Reference in New Issue
Block a user