implement FirstName, LastName, FullName to AcProfile, IAcProfileName, AcUserModelDtoMinBase, etc...
This commit is contained in:
parent
66e14a0fb9
commit
a11c4e7644
|
|
@ -32,7 +32,7 @@ namespace AyCode.Database.DataLayers.Users
|
|||
public TUser? GetUserByEmail(string email) => Session(x => x.GetUserByEmail(email));
|
||||
public Task<TUser?> GetUserByEmailAsync(string email) => SessionAsync(x => x.GetUserByEmail(email));
|
||||
|
||||
public Task<bool> AddUser(TUser user, string profileName, TProfileAddress address)
|
||||
public Task<bool> 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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
namespace AyCode.Interfaces.Profiles.Dtos;
|
||||
|
||||
public interface IAcFullName
|
||||
{
|
||||
string? FullName { get; }
|
||||
string? FirstName { get; set; }
|
||||
string? LastName { get; set; }
|
||||
}
|
||||
|
|
@ -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; }
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
namespace AyCode.Interfaces.Profiles.Dtos;
|
||||
|
||||
public interface IAcProfileName : IAcFullName
|
||||
{
|
||||
string Name { get; set; }
|
||||
//string NickName { get; set; }
|
||||
}
|
||||
|
|
@ -6,4 +6,5 @@ namespace AyCode.Interfaces.Profiles;
|
|||
|
||||
public interface IAcProfile<TAddress> : IAcProfileDtoBase, ITimeStampInfo, IAcAddressRelation<TAddress> where TAddress : class, IAcAddress
|
||||
{
|
||||
public string? GetFullName(string lang = "ENG");
|
||||
}
|
||||
|
|
@ -27,5 +27,8 @@ public abstract class AcUserModelDtoMinBase<TUserDtoMin, TProfile, TProfileDto,
|
|||
Profile = Activator.CreateInstance<TProfileDto>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue