diff --git a/AyCode.Entities/Addresses/AcAddress.cs b/AyCode.Entities/Addresses/AcAddress.cs index 27e871e..1cc4dbd 100644 --- a/AyCode.Entities/Addresses/AcAddress.cs +++ b/AyCode.Entities/Addresses/AcAddress.cs @@ -20,4 +20,22 @@ public abstract class AcAddress : IAcAddress public DateTime Created { get; set; } public DateTime Modified { get; set; } + + protected AcAddress() + { } + + protected AcAddress(Guid id) + { + Id = id; + } + + protected AcAddress(Guid id, string? addressText) : this(id, null, null, addressText) + { } + + protected AcAddress(Guid id, double? latitude, double? longitude, string? addressText) : this(id) + { + Latitude = latitude; + Longitude = longitude; + AddressText = addressText; + } } \ No newline at end of file diff --git a/AyCode.Entities/Profiles/AcProfile.cs b/AyCode.Entities/Profiles/AcProfile.cs index 488884b..d6e8618 100644 --- a/AyCode.Entities/Profiles/AcProfile.cs +++ b/AyCode.Entities/Profiles/AcProfile.cs @@ -2,21 +2,16 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using AyCode.Core.Extensions; +using AyCode.Entities.Addresses; using AyCode.Interfaces.Addresses; using AyCode.Utils.Extensions; +using static System.Runtime.InteropServices.JavaScript.JSType; 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; } @@ -43,6 +38,26 @@ namespace AyCode.Entities.Profiles public DateTime Created { get; set; } public DateTime Modified { get; set; } + protected AcProfile() { } + + protected AcProfile(Guid id) : this() + { + Id = id; + } + + protected AcProfile(Guid id, string name) : this(id) + { + Name = name; + } + + public void SetAddress(TAddress address) + { + if (address.Id.IsNullOrEmpty()) address.Id = Guid.NewGuid(); + + Address = address; + AddressId = address.Id; + } + public string? GetFullName(string lang = "ENG") => GetFullName(FirstName, LastName, lang); public static string? GetFullName(string? firstName, string? lastName, string? lang = "ENG") diff --git a/AyCode.Entities/ServiceProviders/AcCompany.cs b/AyCode.Entities/ServiceProviders/AcCompany.cs index 20e8381..ddd58c6 100644 --- a/AyCode.Entities/ServiceProviders/AcCompany.cs +++ b/AyCode.Entities/ServiceProviders/AcCompany.cs @@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations; using AyCode.Interfaces.Profiles.Dtos; using AyCode.Interfaces.ServiceProviders; using AyCode.Interfaces.Users; +using AyCode.Utils.Extensions; namespace AyCode.Entities.ServiceProviders { @@ -20,8 +21,7 @@ namespace AyCode.Entities.ServiceProviders public Guid OwnerId { get; set; } public Guid ProfileId { get; set; } - [NotMapped] //COMPANY_RENAME - J. - public TProfile Profile { get; set; } + public virtual TProfile Profile { get; set; } [Required] public string Name { get; set; } @@ -60,5 +60,13 @@ namespace AyCode.Entities.ServiceProviders AffiliateId = affiliateId; CommissionPercent = commissionPercent; } + + public void SetProfile(TProfile profile) + { + if (profile.Id.IsNullOrEmpty()) profile.Id = Guid.NewGuid(); + + Profile = profile; + ProfileId = profile.Id; + } } }