using MCVIngenieros.Transactional.Abstractions; using MCVIngenieros.Transactional.Abstractions.Interfaces; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace back.DataModels; [Table("Persons")] public partial class Person: IEntity, ISoftDeletable { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public string Id { get; set; } = null!; [Required, MaxLength(100)] public string Name { get; set; } = null!; public string? ProfilePicture { get; set; } public string? Avatar { get; set; } public string? SocialMediaId { get; set; } [MaxLength(250)] public string? Bio { get; set; } // Optional field for a short biography or description public string CreatedAt { get; set; } = null!; public string? UpdatedAt { get; set; } public int IsDeleted { get; set; } public string? DeletedAt { get; set; } public virtual ICollection Photos { get; set; } = []; public virtual SocialMedia? SocialMedia { get; set; } public virtual User? User { get; set; } public virtual ICollection PhotosNavigation { get; set; } = []; public override int GetHashCode() => HashCode.Combine(Id, Name); public override bool Equals(object? obj) => obj is Person other && Equals(other); public bool Equals(Person? other) { if (other is null) return false; if (ReferenceEquals(this, other)) return true; return Id == other.Id || GetHashCode() == other.GetHashCode(); } public bool IsNull => this is null; public object Clone() => (Person)MemberwiseClone(); public int CompareTo(object? obj) { if(obj is null) return 1; if (obj is not Person other) throw new ArgumentException("Object is not a Person"); return CompareTo(other); } public int CompareTo(Person? other) { if (other is null) return 1; if (ReferenceEquals(this, other)) return 0; return string.Compare(Id, other.Id, StringComparison.OrdinalIgnoreCase); } public const string SystemPersonId = "00000000-0000-0000-0000-000000000001"; public static readonly Person SystemPerson = new() { Id = SystemPersonId, Name = "System", CreatedAt = DateTime.UtcNow.ToString("dd-MM-yyyy HH:mm:ss zz"), User = User.SystemUser }; }