You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.5 KiB
54 lines
1.5 KiB
using Dto;
|
|
using Model;
|
|
using Shared;
|
|
|
|
namespace APIMappers;
|
|
|
|
public static class UserMappeur
|
|
{
|
|
private static GenericMapper<User, UserDto> _mapper = new GenericMapper<User, UserDto>();
|
|
|
|
public static UserDto? ToDto(this User user)
|
|
{
|
|
return user.ToU(_mapper, userDto => new UserDto
|
|
{
|
|
Id = user.Id,
|
|
Username = user.Username,
|
|
ProfilePicture = user.ProfilePicture,
|
|
LastName = user.LastName,
|
|
FirstName = user.FirstName,
|
|
Email = user.Email,
|
|
Password = user.MotDePasse,
|
|
Sexe = user.Sexe,
|
|
Lenght = user.Lenght,
|
|
Weight = user.Weight,
|
|
DateOfBirth = user.DateOfBirth,
|
|
IsCoach = user.Role is Coach
|
|
});
|
|
// ), (activity, entity) => activity.Id = entity.IdActivity);
|
|
|
|
}
|
|
// ochestrateur => api gateway
|
|
// corégraphie => microservice TCP
|
|
|
|
|
|
public static User? ToModel(this UserDto userDto)
|
|
{
|
|
return userDto.ToT(_mapper, user => new User
|
|
{
|
|
Username = userDto.Username,
|
|
ProfilePicture = userDto.ProfilePicture,
|
|
LastName = userDto.LastName,
|
|
FirstName = userDto.FirstName,
|
|
Email = userDto.Email,
|
|
MotDePasse = userDto.Password,
|
|
Sexe = userDto.Sexe,
|
|
Lenght = userDto.Lenght,
|
|
Weight = userDto.Weight,
|
|
DateOfBirth = userDto.DateOfBirth,
|
|
Role = userDto.IsCoach ? new Coach() : new Athlete()
|
|
|
|
});
|
|
}
|
|
|
|
} |