using AyCode.Interfaces.Profiles; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using AyCode.Interfaces.Addresses; using AyCode.Utils.Extensions; namespace AyCode.Entities.Profiles { [Table("Profile")] public abstract class AcProfile : IAcProfile where TAddress : class, IAcAddress { protected AcProfile() { } protected AcProfile(Guid id) : this() { Id = id; } [Key, DatabaseGenerated(DatabaseGeneratedOption.None)] public Guid Id { get; set; } public Guid? UserMediaId { get; set; } [Required] public Guid AddressId { get; set; } [ForeignKey(nameof(AddressId))] public virtual TAddress Address { get; set; } [Required] public string Name { get; set; } public string? FullName => GetFullName("ENG"); public string? FirstName { get; set; } public string? LastName { get; set; } //public string NickName { get; set; } public string? Description { get; set; } public string? ThumbnailUrl { get ; set; } public DateTime Created { get; set; } public DateTime Modified { get; set; } public string? GetFullName(string lang = "ENG") => GetFullName(FirstName, LastName, lang); public static string? GetFullName(string? firstName, string? lastName, string? lang = "ENG") { if (firstName.IsNullOrWhiteSpace()) return lastName; if(lastName.IsNullOrWhiteSpace()) return firstName; if (lang == "ENG") return firstName + " " + lastName; return lastName + " " + firstName; } } }