public async Task <IPersonalData> FindClientAsync(string phrase)
        {
            if (string.IsNullOrEmpty(phrase))
            {
                return(null);
            }

            if (phrase.IsGuid())
            {
                return(await _personalDataRepository.GetAsync(phrase));
            }

            if (phrase.IsValidEmail())
            {
                var client = await _clientAccountsRepository.GetByEmailAsync(phrase);

                if (client == null)
                {
                    return(null);
                }

                return(await _personalDataRepository.GetAsync(client.Id));
            }

            return(await _personalDataRepository.ScanAndFindAsync(itm =>
                                                                  (!string.IsNullOrEmpty(itm.FirstName) && itm.FirstName.ToLower().Contains(phrase)) ||
                                                                  (!string.IsNullOrEmpty(itm.LastName) && itm.LastName.ToLower().Contains(phrase)) ||
                                                                  (!string.IsNullOrEmpty(itm.Email) && itm.Email.ToLower().Contains(phrase))
                                                                  ));
        }
        public async Task <PersonalInformationViewModel> GetPersonalInformation(string returnUrl)
        {
            var userFullData = await _personalDataRepository.GetAsync(CurrentClientId);

            var model = Mapper.Map <PersonalInformationViewModel>(userFullData) ?? new PersonalInformationViewModel();

            model.ReturnUrl   = returnUrl;
            model.NextStepUrl = null; /*GetStepUrl("CountryOfResidence", returnUrl);*/
            model.PrevStepUrl = null;

            return(model);
        }
        public async Task <ClaimsIdentity> CreateUserIdentityAsync(IClientAccount clientAccount, string userName)
        {
            var personalData = await _personalDataRepository.GetAsync(clientAccount.Id);

            var claims = new List <Claim>
            {
                new Claim(ClaimTypes.Name, clientAccount.Email),
                new Claim(ClaimTypes.NameIdentifier, clientAccount.Id),
                new Claim(OpenIdConnectConstants.Claims.Email, clientAccount.Email)
            };

            if (!string.IsNullOrEmpty(personalData.FirstName))
            {
                claims.Add(new Claim(OpenIdConnectConstants.Claims.GivenName, personalData.FirstName));
            }

            if (!string.IsNullOrEmpty(personalData.LastName))
            {
                claims.Add(new Claim(OpenIdConnectConstants.Claims.FamilyName, personalData.LastName));
            }

            if (!string.IsNullOrEmpty(personalData.Country))
            {
                claims.Add(new Claim(OpenIdConnectConstantsExt.Claims.Country, personalData.Country));
            }

            var documents = (await GetDocumentListAsync(clientAccount.Id)).ToList();

            if (documents.Any())
            {
                claims.Add(new Claim(OpenIdConnectConstantsExt.Claims.Documents, string.Join(",", documents)));
            }

            return(new ClaimsIdentity(new GenericIdentity(userName, "Token"), claims));
        }
        public async Task <IPersonalData> FindClientAsync(string phrase)
        {
            if (string.IsNullOrEmpty(phrase))
            {
                return(null);
            }

            if (phrase.IsGuid())
            {
                return(await _personalDataRepository.GetAsync(phrase));
            }

            if (phrase.IsValidEmail())
            {
                var client = await _clientAccountsRepository.GetByEmailAsync(phrase);

                if (client == null)
                {
                    return(null);
                }

                return(await _personalDataRepository.GetAsync(client.Id));
            }

            var phoneNum = phrase.GetDigitsAndSymbols();

            var result = await _personalDataRepository.ScanAndFindAsync(itm =>
                                                                        (!string.IsNullOrEmpty(itm.FullName) && itm.FullName.ToLower().Contains(phrase)) ||
                                                                        (!string.IsNullOrEmpty(itm.Email) && itm.Email.ToLower().Contains(phrase)) ||
                                                                        (!string.IsNullOrEmpty(itm.ContactPhone) && !string.IsNullOrEmpty(phoneNum) &&
                                                                         itm.ContactPhone.Contains(phoneNum))
                                                                        );


            if (result != null)
            {
                return(result);
            }



            result = await FindByWalletAsync(phrase);

            return(result);
        }
Exemple #5
0
        public async Task <IEnumerable <IPersonalData> > GetClientsWithAttemptReq()
        {
            var clientIds = (await _cashOutAttemptRepository.GetAllAttempts())
                            .OrderByDescending(x => x.DateTime)
                            .GroupBy(x => x.ClientId)
                            .Select(x => x.First())
                            .Select(x => x.ClientId).ToArray();
            var pd = (await _personalDataRepository.GetAsync(clientIds)).ToDictionary(x => x.Id);

            return(clientIds.Select(x => pd[x]));
        }
Exemple #6
0
        private async Task HandleUserRegisteredBroadcastAsync(SendBroadcastData <UserRegisteredData> result)
        {
            await _log.WriteInfoAsync("EmailRequestQueueConsumer", "HandleUserRegisteredBroadcastAsync", null, $"DT: {DateTime.UtcNow.ToIsoDateTime()}" +
                                      $"{Environment.NewLine}{result.ToJson()}");

            var personalData = await _personalDataRepository.GetAsync(result.MessageData.ClientId);

            var msg = await _emailGenerator.GenerateUserRegisteredMsg(personalData);

            await _smtpEmailSender.SendBroadcastAsync(result.BroadcastGroup, msg);
        }
Exemple #7
0
        public async Task <EmailMessage> GenerateBankCashInMsg(BankCashInData messageData)
        {
            var personalData = await _personalDataRepository.GetAsync(messageData.ClientId);

            var asset = await _assetsService.TryGetAssetAsync(messageData.AssetId);

            var swiftCredentials = await _swiftCredentialsService.GetCredentialsAsync(asset.Id, personalData);

            var templateVm = new BankCashInTemplate
            {
                AssetId          = messageData.AssetId,
                AssetSymbol      = asset.Symbol,
                ClientName       = personalData.FullName,
                Amount           = messageData.Amount,
                Year             = DateTime.UtcNow.Year.ToString(),
                AccountName      = swiftCredentials.AccountName,
                AccountNumber    = swiftCredentials.AccountNumber,
                Bic              = swiftCredentials.BIC,
                PurposeOfPayment = swiftCredentials.PurposeOfPayment,
                BankAddress      = swiftCredentials.BankAddress,
                CompanyAddress   = swiftCredentials.CompanyAddress
            };

            var msg = new EmailMessage
            {
                Body    = await _templateGenerator.GenerateAsync("BankCashInTemplate", templateVm),
                Subject = EmailResources.BankCashIn_Subject,
                IsHtml  = true
            };

            //var stream = new MemoryStream();
            //await _srvPdfGenerator.PrintInvoice(stream, messageData.ClientId, messageData.Amount, messageData.AssetId);

            //msg.Attachments = new[]
            //{
            //    new EmailAttachment {ContentType = MediaTypeNames.Application.Pdf,
            //        FileName = "invoice.pdf", Stream = stream}
            //};

            return(msg);
        }
        public async Task NotifyAsync(IPaymentTransaction pt)
        {
            var pd = await _personalDataRepository.GetAsync(pt.ClientId);


            var body =
                $"Client: {pd.Email}, Payment system amount: {pt.AssetId} {pt.Amount.MoneyToStr()}, Deposited amount: {pt.DepositedAssetId} {pt.DepositedAmount}, PaymentSystem={pt.PaymentSystem}";

            await
            _emailSender.BroadcastEmailAsync(BroadcastGroup.Payments,
                                             "Payment notification Ok", body);
        }
Exemple #9
0
        public async Task <IEnumerable <IPersonalData> > GetAccountsToCheck()
        {
            var ids = await _kycRepository.GetClientsByStatus(KycStatus.Pending);

            return(await _personalDataRepository.GetAsync(ids));
        }
        public async Task <IEnumerable <IPersonalData> > GetAccountsToCheck()
        {
            var ids = (await _kycRepository.GetClientsByStatus(KycStatus.Pending)).ToList();

            return((await _personalDataRepository.GetAsync(ids)).OrderBy(x => ids.IndexOf(x.Id)).ToList());;
        }