migrare UI in WebAssembly + integrare Serviciu stocare info pe web + WebToken

This commit is contained in:
andrei-mihnea-cerbu
2024-04-10 06:57:48 +03:00
parent 9977a9b5f5
commit adba50e70b
1915 changed files with 16113 additions and 99991 deletions
+56
View File
@@ -0,0 +1,56 @@
using System.Text.Json;
using HealthcareManagerUiWebAssem.Models;
using HealthcareManagerUiWebAssem.Services.Profile;
namespace HealthcareManagerUiWebAssem.Services.User;
public class UserService
{
public Guid UserId { get; private set; }
public void SetUserId(Guid id)
{
UserId = id;
}
public async Task<UserUpdateProfileModel?> InitializeProfile(string role, IProfileService profileService)
{
var response = role switch
{
"doctor" => await profileService.GetDoctorById(UserId),
"patient" => await profileService.GetPatientById(UserId),
_ => null
};
if (response.Data != null)
{
var jsonOptions = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
if (role.Equals("doctor", StringComparison.OrdinalIgnoreCase))
{
var doctor = JsonSerializer.Deserialize<Doctor>(response.Data.ToString(), jsonOptions);
return new UserUpdateProfileModel
{
Id = doctor.Id,
Name = doctor.Name,
Email = doctor.Email,
Password = doctor.Password,
Description = doctor.Description
};
}
if (role.Equals("patient", StringComparison.OrdinalIgnoreCase))
{
var patient = JsonSerializer.Deserialize<Patient>(response.Data.ToString(), jsonOptions);
return new UserUpdateProfileModel
{
Id = patient.Id,
Name = patient.Name,
Email = patient.Email,
Password = patient.Password
};
}
}
return new UserUpdateProfileModel();
}
}