Merge branch 'master' of http://git2.aycode.com/Adam/AyCode.Core
This commit is contained in:
commit
51f7d745d8
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
namespace AyCode.Core.Helpers
|
||||
{
|
||||
public static class AcCharGenerator
|
||||
public static class AcCharsGenerator
|
||||
{
|
||||
public static readonly char[] Letters;
|
||||
public static readonly char[] Numbers;
|
||||
public static readonly char[] LettersAndNumbers;
|
||||
|
||||
static AcCharGenerator()
|
||||
static AcCharsGenerator()
|
||||
{
|
||||
//"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
|
||||
|
|
@ -23,6 +23,7 @@ namespace AyCode.Core.Helpers
|
|||
private static char[] GetRandomChars(int minLength, int maxLength) => GetRandomChars(LettersAndNumbers, minLength, maxLength);
|
||||
private static char[] GetRandomChars(char[] sourceChars, int minLength, int maxLength)
|
||||
{
|
||||
if (minLength < 1) throw new ArgumentOutOfRangeException(nameof(minLength), "must have length greater than or equal to 1");
|
||||
var random = new Random();
|
||||
return Enumerable.Repeat(sourceChars, random.Next(minLength, maxLength)).Select(s => s[random.Next(s.Length)]).ToArray();
|
||||
}
|
||||
|
|
@ -32,7 +33,7 @@ namespace AyCode.Core.Helpers
|
|||
return new string(GetRandomChars(AcConst.MinUserTokenLength, AcConst.MaxUserTokenLength));
|
||||
}
|
||||
|
||||
public static string NewPassword()
|
||||
public static string NewPassword(int minLength = AcConst.MinPasswordLength, int maxLength = AcConst.MaxPasswordLength)
|
||||
{
|
||||
return new string(GetRandomChars(AcConst.MinPasswordLength, AcConst.MaxPasswordLength));
|
||||
}
|
||||
|
|
@ -55,8 +55,11 @@ namespace AyCode.Database.DataLayers.Users
|
|||
=> GetAllModelDtoAsync<TUserModelDto, TUser>();
|
||||
|
||||
public Task<List<TUser>> GetUsersAsync() => SessionAsync(ctx => ctx.Users.ToList());
|
||||
//public Task<List<TUserModelDto>> GetUserEmails() => SessionAsync(ctx => ctx.Users.Select(x => new UserModelDtoEmail(x)).ToList());
|
||||
|
||||
|
||||
public virtual Task<TUser?> UpdateUserAsync(TUser user) => UpdateSafeAsync(user);
|
||||
|
||||
public Task<bool> AddUserAsync(TUser user)
|
||||
{
|
||||
return TransactionAsync(ctx => ctx.AddUser(user));
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ public interface IAcLoginServiceCommon<TUser, TProfile, TCompany, TUserToService
|
|||
public bool Logout();
|
||||
public Task<bool> LogoutAsync();
|
||||
|
||||
public AcErrorCode Registration(string email, string password, string? phoneNumber = null);
|
||||
public AcErrorCode Registration(Guid userId, string email, string password, string? phoneNumber = null);
|
||||
public Task<AcErrorCode> RegistrationAsync(string email, string password, string? phoneNumber = null);
|
||||
public Task<AcErrorCode> RegistrationAsync(Guid userId, string email, string password, string? phoneNumber = null);
|
||||
public AcErrorCode Registration(string email, string password, string? phoneNumber = null, Guid? referralId = null);
|
||||
public AcErrorCode Registration(Guid userId, string email, string password, string? phoneNumber = null, Guid? referralId = null);
|
||||
public Task<AcErrorCode> RegistrationAsync(string email, string password, string? phoneNumber = null, Guid? referralId = null);
|
||||
public Task<AcErrorCode> RegistrationAsync(Guid userId, string email, string password, string? phoneNumber = null, Guid? referralId = null);
|
||||
}
|
||||
|
|
@ -28,8 +28,7 @@ public abstract class AcUserModelDtoBase<TUserDto, TProfileDto, TCompany, TUserT
|
|||
protected AcUserModelDtoBase(IAcUserDtoBase<TProfileDto, TCompany, TUserToCompany> user) : base(user)
|
||||
{
|
||||
ProfileDto.AddressId = user.Profile.AddressId;
|
||||
UserDto.AffiliateId = user.AffiliateId;
|
||||
|
||||
|
||||
if (user.ServiceProviders.Count == 0) return;
|
||||
|
||||
//így proxy error lesz... - J.
|
||||
|
|
|
|||
|
|
@ -39,6 +39,17 @@ public abstract class AcUserModelDtoDetailBase<TUserDtoDetail, TProfileDto, TCom
|
|||
|
||||
protected AcUserModelDtoDetailBase(IAcUserDtoDetailBase<TProfileDto, TCompany, TUserToCompany, TAddressDto> user) : base(user)
|
||||
{
|
||||
UserDto.Id = user.Id;
|
||||
UserDto.ProfileId = user.ProfileId;
|
||||
UserDto.EmailAddress = user.EmailAddress;
|
||||
UserDto.EmailConfirmed = user.EmailConfirmed;
|
||||
UserDto.PhoneNumber = user.PhoneNumber;
|
||||
UserDto.RefferalId = user.RefferalId;
|
||||
UserDto.AffiliateId = user.AffiliateId;
|
||||
UserDto.RefreshToken = user.RefreshToken;
|
||||
UserDto.Created = user.Created;
|
||||
UserDto.Modified = user.Modified;
|
||||
|
||||
var address = Activator.CreateInstance<TAddressDto>();
|
||||
|
||||
address.Id = user.Profile.AddressId;
|
||||
|
|
@ -47,10 +58,19 @@ public abstract class AcUserModelDtoDetailBase<TUserDtoDetail, TProfileDto, TCom
|
|||
address.Longitude = user.Profile.Address.Longitude;
|
||||
|
||||
ProfileDto.Address = address;
|
||||
}
|
||||
|
||||
UserDto.EmailAddress = user.EmailAddress;
|
||||
UserDto.PhoneNumber = user.PhoneNumber;
|
||||
UserDto.Created = user.Created;
|
||||
UserDto.Modified = user.Modified;
|
||||
public void CopyUserDtoValuesToUser(IAcUserDtoDetailBase<TProfileDto, TCompany, TUserToCompany, TAddressDto> user)
|
||||
{
|
||||
base.CopyUserDtoValuesToUser(user);
|
||||
|
||||
user.ProfileId = UserDto.ProfileId;
|
||||
user.EmailAddress = UserDto.EmailAddress;
|
||||
user.EmailConfirmed = UserDto.EmailConfirmed;
|
||||
user.PhoneNumber = UserDto.PhoneNumber;
|
||||
user.RefferalId = UserDto.RefferalId;
|
||||
//user.RefreshToken = UserDto.RefreshToken; //Ezzel mi legyen?! - J.
|
||||
user.Created = UserDto.Created;
|
||||
user.Modified = UserDto.Modified;
|
||||
}
|
||||
}
|
||||
|
|
@ -34,6 +34,12 @@ public abstract class AcUserModelDtoMinBase<TUserDtoMin, TProfileDto> : AcModelD
|
|||
//Profile.NickName = user.Profile.NickName;
|
||||
}
|
||||
|
||||
public void CopyUserDtoValuesToUser(IAcUserDtoMinBase<TProfileDto> user)
|
||||
{
|
||||
user.Id = UserDto.Id;
|
||||
user.AffiliateId = UserDto.AffiliateId;
|
||||
}
|
||||
|
||||
//public virtual TUserDtoMin CreateMainEntity()
|
||||
//{
|
||||
// var user = base.CreateMainEntity();
|
||||
|
|
|
|||
|
|
@ -83,11 +83,13 @@ public class AcLoginServiceServer<TResultLoggedInModel, TDal, TDbContext, TUser,
|
|||
return TaskHelper.ToThreadPoolTask(Logout);
|
||||
}
|
||||
|
||||
public virtual AcErrorCode Registration(string email, string password, string? phoneNumber = null)
|
||||
=> Registration(Guid.NewGuid(), email, password, phoneNumber);
|
||||
public virtual AcErrorCode Registration(string email, string password, string? phoneNumber = null, Guid? referralId = null)
|
||||
=> Registration(Guid.NewGuid(), email, password, phoneNumber, referralId);
|
||||
|
||||
public virtual AcErrorCode Registration(Guid userId, string email, string password, string? phoneNumber = null)
|
||||
public virtual AcErrorCode Registration(Guid userId, string email, string password, string? phoneNumber = null, Guid? referralId = null)
|
||||
{
|
||||
email = email.ToLower();
|
||||
|
||||
if ((phoneNumber != null && !AcValidate.IsValidPhoneNumberFormat(phoneNumber, out var errorCode)) ||
|
||||
!AcValidate.IsValidEmailAndPasswordFormat(email, password, out errorCode)) return errorCode;
|
||||
|
||||
|
|
@ -108,11 +110,11 @@ public class AcLoginServiceServer<TResultLoggedInModel, TDal, TDbContext, TUser,
|
|||
}
|
||||
|
||||
|
||||
public virtual Task<AcErrorCode> RegistrationAsync(string email, string password, string? phoneNumber = null)
|
||||
=> RegistrationAsync(Guid.NewGuid(), email, password, phoneNumber);
|
||||
public virtual Task<AcErrorCode> RegistrationAsync(string email, string password, string? phoneNumber = null, Guid? referralId = null)
|
||||
=> RegistrationAsync(Guid.NewGuid(), email, password, phoneNumber, referralId);
|
||||
|
||||
public virtual Task<AcErrorCode> RegistrationAsync(Guid userId, string email, string password, string? phoneNumber = null)
|
||||
=> TaskHelper.ToThreadPoolTask(() => Registration(userId, email, password, phoneNumber));
|
||||
public virtual Task<AcErrorCode> RegistrationAsync(Guid userId, string email, string password, string? phoneNumber = null, Guid? referralId = null)
|
||||
=> TaskHelper.ToThreadPoolTask(() => Registration(userId, email, password, phoneNumber, referralId));
|
||||
|
||||
public virtual bool SendConfirmationToken(string? email, string confirmationToken)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,22 +37,22 @@ public class AcLoginServiceClient<TUser, TProfile, TCompany, TUserToServiceProvi
|
|||
return TaskHelper.ToThreadPoolTask(Logout);
|
||||
}
|
||||
|
||||
public virtual AcErrorCode Registration(string email, string password, string? phoneNumber = null)
|
||||
public virtual AcErrorCode Registration(string email, string password, string? phoneNumber = null, Guid? referralId = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public AcErrorCode Registration(Guid userId, string email, string password, string? phoneNumber = null)
|
||||
public AcErrorCode Registration(Guid userId, string email, string password, string? phoneNumber = null, Guid? referralId = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual Task<AcErrorCode> RegistrationAsync(string email, string password, string? phoneNumber = null)
|
||||
public virtual Task<AcErrorCode> RegistrationAsync(string email, string password, string? phoneNumber = null, Guid? referralId = null)
|
||||
{
|
||||
return TaskHelper.ToThreadPoolTask(() => Registration(email, password, phoneNumber));
|
||||
}
|
||||
|
||||
public Task<AcErrorCode> RegistrationAsync(Guid userId, string email, string password, string? phoneNumber = null)
|
||||
public Task<AcErrorCode> RegistrationAsync(Guid userId, string email, string password, string? phoneNumber = null, Guid? referralId = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,37 +127,39 @@ public interface ISignalRMessage
|
|||
[MessagePackObject]
|
||||
public sealed class SignalResponseJsonMessage : ISignalResponseMessage<string>
|
||||
{
|
||||
[Key(0)] public SignalResponseStatus Status { get; set; }
|
||||
[Key(0)] public int MessageTag { get; set; }
|
||||
|
||||
[Key(1)] public string? ResponseData { get; set; } = null;
|
||||
[Key(1)] public SignalResponseStatus Status { get; set; }
|
||||
|
||||
[Key(2)] public string? ResponseData { get; set; } = null;
|
||||
|
||||
public SignalResponseJsonMessage(){}
|
||||
|
||||
public SignalResponseJsonMessage(SignalResponseStatus status)
|
||||
public SignalResponseJsonMessage(int messageTag, SignalResponseStatus status)
|
||||
{
|
||||
Status = status;
|
||||
MessageTag = messageTag;
|
||||
}
|
||||
|
||||
public SignalResponseJsonMessage(SignalResponseStatus status, object? responseData) : this(status)
|
||||
public SignalResponseJsonMessage(int messageTag, SignalResponseStatus status, object? responseData) : this(messageTag, status)
|
||||
{
|
||||
if (responseData is string)
|
||||
ResponseData = responseData as string;
|
||||
if (responseData is string stringdata)
|
||||
ResponseData = stringdata;
|
||||
else ResponseData = responseData.ToJson();
|
||||
}
|
||||
|
||||
public SignalResponseJsonMessage(SignalResponseStatus status, string? responseDataJson) : this(status)
|
||||
public SignalResponseJsonMessage(int messageTag, SignalResponseStatus status, string? responseDataJson) : this(messageTag, status)
|
||||
{
|
||||
ResponseData = responseDataJson;
|
||||
}
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class SignalResponseMessage<TResponseData>(SignalResponseStatus status, TResponseData? responseData) : ISignalResponseMessage<TResponseData>
|
||||
public sealed class SignalResponseMessage<TResponseData>(int messageTag, SignalResponseStatus status, TResponseData? responseData) : ISignalResponseMessage<TResponseData>
|
||||
{
|
||||
[Key(0)]
|
||||
public SignalResponseStatus Status { get; set; } = status;
|
||||
[Key(1)]
|
||||
public TResponseData? ResponseData { get; set; } = responseData;
|
||||
[Key(0)] public int MessageTag { get; set; }
|
||||
[Key(1)] public SignalResponseStatus Status { get; set; } = status;
|
||||
[Key(2)] public TResponseData? ResponseData { get; set; } = responseData;
|
||||
}
|
||||
|
||||
public sealed class SignalResponseStatusMessage(SignalResponseStatus status) : ISignalRMessage
|
||||
|
|
@ -179,6 +181,7 @@ public interface ISignalResponseMessage<TResponseData> : ISignalResponseMessage
|
|||
|
||||
public interface ISignalResponseMessage : ISignalRMessage
|
||||
{
|
||||
int MessageTag { get; set; }
|
||||
SignalResponseStatus Status { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue