MyBookmark/Modules.User.Domain/Entities/User/User.cs
THE_KONDRAT 7b16d72329 ui and login
mongo => postgres
2024-11-03 16:08:39 +03:00

42 lines
1.3 KiB
C#

using Modules.User.Domain.Gateways;
namespace Modules.User.Domain.Entities.User;
public class User
{
public Guid Id { get; private set; }
public Account.Account Account { get; private set; } = default!;
public string NickName { get; private set; } = default!;
public string? FirstName { get; private set; }
public string? SecondName { get; private set; }
public string? LastName { get; private set; }
public Guid? AvatarId { get; private set; }
public Guid? LanguageId { get; private set; }
private User() { }
public User(Models.User model)
{
Id = model.Id;
Account = new Account.Account(model.Account);
NickName = model.NickName;
FirstName = model.FirstName;
SecondName = model.LastName;
LastName = model.LastName;
AvatarId = model.AvatarId;
LanguageId = model.LanguageId;
}
public static User Create(string email, string password, IPasswordGateway passwordHasher, string nickname)
{
if (string.IsNullOrWhiteSpace(nickname)) throw new ArgumentNullException(nameof(nickname));
return new User
{
Account = Entities.Account.Account.Create(email, password, passwordHasher),
NickName = nickname,
};
}
}