Try to Handle Commands ...
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
using xBotService.Models;
|
||||
using xCommons.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xBotService.Models.Dtos;
|
||||
using xBotService.Configuration;
|
||||
using xBotService.Models.Entities;
|
||||
|
||||
namespace xBotService.Extensions
|
||||
{
|
||||
@@ -42,6 +45,94 @@ namespace xBotService.Extensions
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check a User is Verified or not ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsVerified(
|
||||
this XBotUser source
|
||||
)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
source.VerifiedOn.HasValue;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check a User is Verified or not ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsVerified(
|
||||
this XBotUserDto source
|
||||
)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
source.VerifiedOn.HasValue;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check a User's Verification Code is Expired or not ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="configuration"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsExpired(
|
||||
this XBotUser source,
|
||||
XBotServiceConfiguration configuration
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (configuration.IsNull() ||
|
||||
source.IsNullOrDefault() ||
|
||||
!source.VerifiedOn.HasValue ||
|
||||
configuration.VerificationCodeTTL <= 0)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var result = source.VerifiedOn.Value.IsExpiredTTL(configuration.VerificationCodeTTL);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check a User's Verification Code is Expired or not ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="configuration"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsExpired(
|
||||
this XBotUserDto source,
|
||||
XBotServiceConfiguration configuration
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (configuration.IsNull() ||
|
||||
source.IsNullOrDefault() ||
|
||||
!source.VerifiedOn.HasValue ||
|
||||
configuration.VerificationCodeTTL <= 0)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var result = source.VerifiedOn.Value.IsExpiredTTL(configuration.VerificationCodeTTL);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Normalize ot Update Request ...
|
||||
/// </summary>
|
||||
@@ -98,7 +189,7 @@ namespace xBotService.Extensions
|
||||
|
||||
//
|
||||
result = new();
|
||||
result.UpdateData(source);
|
||||
result = source.MapConvert<XBotSendMessageRequestDto, XBotSendMessageRequest>();
|
||||
|
||||
//
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user