AyCode.Core/AyCode.Entities/Users/UserBase.cs

61 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Interfaces.Profiles;
using AyCode.Interfaces.Users;
namespace AyCode.Entities.Users
{
[Table("Users")]
public abstract class UserBase<TProfile> : IUserBase<TProfile> where TProfile : class, IAcProfileBase
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
public Guid Id { get; set; }
[Column("Email")]
public string EmailAddress { get; set; }
//public string NormalizedEmail { get; set; }
public string PhoneNumber { get; set; }
public string Password { get; set; }
public string? RefreshToken { get; set; }
public bool EmailConfirmed { get; set; }
public Guid? ProfileId { get; }
[ForeignKey(nameof(ProfileId))]
public virtual TProfile Profile { get; set; }
public DateTime Created { get; set; }
public DateTime Modified { get; set; }
protected UserBase() { }
protected UserBase(string email, string password) : this(Guid.NewGuid(), email, password) { }
protected UserBase(Guid id, string email, string password) : this()
{
Id = id;
EmailAddress = email;
Password = password;
}
protected UserBase(string email, string phoneNumber, string password) : this(Guid.NewGuid(), email, phoneNumber, password) { }
protected UserBase(Guid id, string email, string phoneNumber, string password) : this(id, email, password)
{
PhoneNumber = phoneNumber;
}
protected UserBase(string email, string phoneNumber, string password, string refreshToken) : this(Guid.NewGuid(), email, phoneNumber, password, refreshToken) { }
protected UserBase(Guid id, string email, string phoneNumber, string password, string refreshToken) : this(id, email, phoneNumber, password)
{
RefreshToken = refreshToken;
}
}
}