From a11c4e76448f0b31b8ea42a258b44b71e9042c3f Mon Sep 17 00:00:00 2001 From: "jozsef.b@aycode.com" <9Rj@D}fVwBaN> Date: Tue, 9 Apr 2024 15:31:45 +0200 Subject: [PATCH] implement FirstName, LastName, FullName to AcProfile, IAcProfileName, AcUserModelDtoMinBase, etc... --- .../DataLayers/Users/AcUserDalBase.cs | 4 +++- AyCode.Entities/Profiles/AcProfile.cs | 20 +++++++++++++++++++ .../Profiles/Dtos/IAcFullName.cs | 8 ++++++++ .../Profiles/Dtos/IAcProfileDtoBase.cs | 3 +-- .../Profiles/Dtos/IAcProfileName.cs | 7 +++++++ AyCode.Interfaces/Profiles/IAcProfile.cs | 1 + AyCode.Models/Users/AcUserModelDtoMinBase.cs | 3 +++ 7 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 AyCode.Interfaces/Profiles/Dtos/IAcFullName.cs create mode 100644 AyCode.Interfaces/Profiles/Dtos/IAcProfileName.cs diff --git a/AyCode.Database/DataLayers/Users/AcUserDalBase.cs b/AyCode.Database/DataLayers/Users/AcUserDalBase.cs index aa98615..64675fe 100644 --- a/AyCode.Database/DataLayers/Users/AcUserDalBase.cs +++ b/AyCode.Database/DataLayers/Users/AcUserDalBase.cs @@ -32,7 +32,7 @@ namespace AyCode.Database.DataLayers.Users public TUser? GetUserByEmail(string email) => Session(x => x.GetUserByEmail(email)); public Task GetUserByEmailAsync(string email) => SessionAsync(x => x.GetUserByEmail(email)); - public Task AddUser(TUser user, string profileName, TProfileAddress address) + public Task AddUser(TUser user, string profileName, TProfileAddress address, string? firstName = null, string? lastName = null) { return TransactionAsync(ctx => { @@ -40,6 +40,8 @@ namespace AyCode.Database.DataLayers.Users profile.Id = Guid.NewGuid(); profile.Name = profileName; + profile.FirstName = firstName; + profile.LastName = lastName; profile.Address = address; user.Profile= profile; diff --git a/AyCode.Entities/Profiles/AcProfile.cs b/AyCode.Entities/Profiles/AcProfile.cs index b73ae71..138b1c6 100644 --- a/AyCode.Entities/Profiles/AcProfile.cs +++ b/AyCode.Entities/Profiles/AcProfile.cs @@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using AyCode.Interfaces.Addresses; +using AyCode.Utils.Extensions; namespace AyCode.Entities.Profiles { @@ -26,11 +27,30 @@ namespace AyCode.Entities.Profiles [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; + } } } diff --git a/AyCode.Interfaces/Profiles/Dtos/IAcFullName.cs b/AyCode.Interfaces/Profiles/Dtos/IAcFullName.cs new file mode 100644 index 0000000..d4c3d31 --- /dev/null +++ b/AyCode.Interfaces/Profiles/Dtos/IAcFullName.cs @@ -0,0 +1,8 @@ +namespace AyCode.Interfaces.Profiles.Dtos; + +public interface IAcFullName +{ + string? FullName { get; } + string? FirstName { get; set; } + string? LastName { get; set; } +} \ No newline at end of file diff --git a/AyCode.Interfaces/Profiles/Dtos/IAcProfileDtoBase.cs b/AyCode.Interfaces/Profiles/Dtos/IAcProfileDtoBase.cs index ce248b3..c33f12b 100644 --- a/AyCode.Interfaces/Profiles/Dtos/IAcProfileDtoBase.cs +++ b/AyCode.Interfaces/Profiles/Dtos/IAcProfileDtoBase.cs @@ -4,8 +4,7 @@ using AyCode.Interfaces.MediaInfo; namespace AyCode.Interfaces.Profiles.Dtos; -public interface IAcProfileDtoBase : IEntityGuid, IMediaInfo, IAcAddressForeignKey +public interface IAcProfileDtoBase : IEntityGuid, IAcProfileName, IMediaInfo, IAcAddressForeignKey { - string Name { get; set; } string? Description { get; set; } } \ No newline at end of file diff --git a/AyCode.Interfaces/Profiles/Dtos/IAcProfileName.cs b/AyCode.Interfaces/Profiles/Dtos/IAcProfileName.cs new file mode 100644 index 0000000..d07deb5 --- /dev/null +++ b/AyCode.Interfaces/Profiles/Dtos/IAcProfileName.cs @@ -0,0 +1,7 @@ +namespace AyCode.Interfaces.Profiles.Dtos; + +public interface IAcProfileName : IAcFullName +{ + string Name { get; set; } + //string NickName { get; set; } +} \ No newline at end of file diff --git a/AyCode.Interfaces/Profiles/IAcProfile.cs b/AyCode.Interfaces/Profiles/IAcProfile.cs index f552a8f..b712f87 100644 --- a/AyCode.Interfaces/Profiles/IAcProfile.cs +++ b/AyCode.Interfaces/Profiles/IAcProfile.cs @@ -6,4 +6,5 @@ namespace AyCode.Interfaces.Profiles; public interface IAcProfile : IAcProfileDtoBase, ITimeStampInfo, IAcAddressRelation where TAddress : class, IAcAddress { + public string? GetFullName(string lang = "ENG"); } \ No newline at end of file diff --git a/AyCode.Models/Users/AcUserModelDtoMinBase.cs b/AyCode.Models/Users/AcUserModelDtoMinBase.cs index 4fadb48..b1e1f39 100644 --- a/AyCode.Models/Users/AcUserModelDtoMinBase.cs +++ b/AyCode.Models/Users/AcUserModelDtoMinBase.cs @@ -27,5 +27,8 @@ public abstract class AcUserModelDtoMinBase(); Profile.Id = user.Profile.Id; Profile.Name = user.Profile.Name; + Profile.FirstName = user.Profile.FirstName; + Profile.LastName = user.Profile.LastName; + //Profile.NickName = user.Profile.NickName; } } \ No newline at end of file