public (bool ValidationResult, string ValidationMessage) ValidateGetCode(string phoneNumber) { if (string.IsNullOrWhiteSpace(phoneNumber)) { return(false, ErrorDictionary.GetErrorMessage(6, _culture)); } else if (!Regex.Match(phoneNumber, RegexTemplates.PhoneTemplate).Success) { return(false, ErrorDictionary.GetErrorMessage(6, _culture)); } var person = _authorizationRepository.GetPerson(phoneNumber).Result; if (person != null && person.TemporaryCodeTime.HasValue) { var timeDifference = (DateTime.UtcNow - person.TemporaryCodeTime.Value).TotalSeconds; if (timeDifference < 30) { return(false, ErrorDictionary.GetErrorMessage(45, _culture)); } } return(true, string.Empty); }
public async Task <AuthorizationPersonModel> GetPerson(string phoneNumber, CancellationToken cancellationToken = default) { var dalPerson = await _authorizationRepository.GetPerson(phoneNumber, cancellationToken); return(ConvertPersonModel(dalPerson)); }