public async Task <bool> CreateAsync(CreateAuditMessage message)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                try
                {
                    var entity = new AuditMessage
                    {
                        CreationTimestamp = message.Timestamp,
                        MessageId         = message.MessageId,
                        MessageType       = message.MessageType,
                        CustomerId        = message.CustomerId,
                        SubjectTemplateId = message.SubjectTemplateId,
                        MessageTemplateId = message.MessageTemplateId,
                        Source            = message.Source,
                        CallType          = message.CallType,
                        FormattingStatus  = message.FormattingStatus,
                        FormattingComment = message.FormattingComment,
                        DeliveryStatus    = DeliveryStatus.Pending
                    };

                    context.AuditMessages.Add(entity);

                    await context.SaveChangesAsync();

                    return(true);
                }
                catch (DbUpdateException e)
                {
                    _log.Warning("Error creating audit message entry", e);
                    return(false);
                }
            }
        }
Example #2
0
 public async Task <ICollection <Guid> > GetAll()
 {
     using (var context = _msSqlContextFactory.CreateDataContext())
     {
         return(await context.ActiveCampaigns.Select(c => c.Id).ToListAsync());
     }
 }
Example #3
0
        public async Task UpdateByCurrencyAndOperationType(UpdateVoucherOperationsStatistic partnerStatistic)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = await context.VoucherOperationsStatistics
                             .FirstOrDefaultAsync(x =>
                                                  x.PartnerId == partnerStatistic.PartnerId &&
                                                  x.Currency == partnerStatistic.Currency &&
                                                  x.OperationType == partnerStatistic.OperationType);

                if (entity != null)
                {
                    entity.TotalCount++;
                    entity.Sum += partnerStatistic.Amount;

                    context.Update(entity);
                }
                else
                {
                    var newEntity = new VoucherOperationsStatisticsEntity()
                    {
                        PartnerId     = partnerStatistic.PartnerId,
                        Currency      = partnerStatistic.Currency,
                        Sum           = partnerStatistic.Amount,
                        OperationType = partnerStatistic.OperationType,
                        TotalCount    = 1
                    };

                    context.VoucherOperationsStatistics.Add(newEntity);
                }

                await context.SaveChangesAsync();
            }
        }
        public async Task AddReferralStakeAsync(ReferralStakeDto referralStake)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var historyEntity       = TransactionHistoryEntity.CreateForReferralStakeTokensReservation(referralStake);
                var referralStakeEntity = ReferralStakeEntity.Create(referralStake);

                var campaign = await context.Campaigns.FindAsync(referralStake.CampaignId);

                if (campaign != null && campaign.CampaignName != referralStake.CampaignName)
                {
                    campaign.CampaignName = referralStake.CampaignName;
                }

                if (campaign == null)
                {
                    campaign = CampaignEntity.Create(referralStake.CampaignId, referralStake.CampaignName);
                }

                referralStakeEntity.Campaign = campaign;

                context.ReferralStakes.Add(referralStakeEntity);
                context.TransactionHistories.Add(historyEntity);

                await context.SaveChangesAsync();
            }
        }
        public async Task AddAsync(BonusCashInDto bonusCashIn)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var historyEntity = TransactionHistoryEntity.Create(bonusCashIn);
                var bonusEntity   = BonusCashInEntity.Create(bonusCashIn);

                var campaign = await context.Campaigns.FindAsync(bonusCashIn.CampaignId);

                if (campaign != null && campaign.CampaignName != bonusCashIn.CampaignName)
                {
                    campaign.CampaignName = bonusCashIn.CampaignName;
                }

                if (campaign == null)
                {
                    campaign = CampaignEntity.Create(bonusCashIn.CampaignId, bonusCashIn.CampaignName);
                }

                bonusEntity.Campaign = campaign;

                context.BonusCashIns.Add(bonusEntity);
                context.TransactionHistories.Add(historyEntity);

                await context.SaveChangesAsync();
            }
        }
Example #6
0
        public async Task AddAsync(TransactionReport report)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                await context.TransactionReports.AddAsync(_mapper.Map <TransactionReportEntity>(report));

                await context.SaveChangesAsync();
            }
        }
Example #7
0
        public async Task <CustomerProfileModel> GetCustomerProfileAsync(Guid customerId)
        {
            using (var context = _msSqlContextFactory.CreateDataContext())
            {
                var customerProfile = await context.CustomerProfiles.FirstOrDefaultAsync(c => c.CustomerId == customerId);

                return(_mapper.Map <CustomerProfileModel>(customerProfile));
            }
        }
        public async Task <byte[]> GetPublicKeyAsync(string address)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = await context.Wallets.FindAsync(address);

                return(entity?.PublicKey);
            }
        }
        public async Task <GlobalCurrencyRate> GetAsync()
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = await context.GlobalCurrencyRates.FirstOrDefaultAsync();

                return(_mapper.Map <GlobalCurrencyRate>(entity));
            }
        }
Example #10
0
        public async Task<Transfer> GetByIdAsync(Guid transferId)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = await context.Transfers.FindAsync(transferId);

                return _mapper.Map<Transfer>(entity);
            }
        }
Example #11
0
        public async Task <IReadOnlyList <CountryOfResidence> > GetAllAsync()
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entities = await context.CountriesOfResidence.ToListAsync();

                return(_mapper.Map <IReadOnlyList <CountryOfResidence> >(entities));
            }
        }
        public async Task <CustomerBonuses> GetAsync(Guid customerId)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = await context.CustomerBonuses.SingleOrDefaultAsync(o => o.CustomerId == customerId);

                return(_mapper.Map <CustomerBonuses>(entity));
            }
        }
Example #13
0
        public async Task <ILastKnownStats> GetLastKnownStatsAsync()
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var result = await context.LastKnownStats.FirstOrDefaultAsync();

                return(result);
            }
        }
Example #14
0
        public async Task <Guid?> GetTierByCustomerIdAsync(Guid customerId)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = await context.CustomerTiers.FirstOrDefaultAsync(o => o.CustomerId == customerId);

                return(entity?.TierId);
            }
        }
Example #15
0
        public async Task <IReadOnlyList <CurrencyRate> > GetAllAsync()
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entities = await context.CurrencyRates.ToListAsync();

                return(_mapper.Map <List <CurrencyRate> >(entities));
            }
        }
        public async Task <IMaintenanceDetails> GetMaintenanceStatusAsync()
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var result = await context.ActiveMaintenances.SingleOrDefaultAsync();

                return(result);
            }
        }
        public async Task <DateTime?> Get()
        {
            using (var context = _msSqlContextFactory.CreateDataContext())
            {
                var date = await context.Configuration.FirstOrDefaultAsync();

                return(date?.LastProcessedDate);
            }
        }
Example #18
0
        public async Task <PartnerCredentials> GetByClientIdAsync(string clientId)
        {
            clientId = _hashingHelper.Sha256HashEncoding1252(clientId);
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = await context.PartnerCredentials.FirstOrDefaultAsync(p => p.ClientId == clientId);

                return(_mapper.Map <PartnerCredentials>(entity));
            }
        }
Example #19
0
 public async Task <Guid[]> GetCampaignContributionsIdForCustomerAsync(Guid customerId)
 {
     using (var context = _msSqlContextFactory.CreateDataContext())
     {
         return(await context.CampaignsContributions
                .AsNoTracking()
                .Where(c => c.CustomerId == customerId)
                .Select(c => c.CampaignId).ToArrayAsync());
     }
 }
Example #20
0
        public async Task <Operation> GetByTransferIdAsync(Guid transferId, OperationType type)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = await context.Operations
                             .Where(i => i.TransferId == transferId && i.Type == type)
                             .FirstAsync();

                return(_mapper.Map <Operation>(entity));
            }
        }
        public async Task <IReadOnlyList <ReferralLeadProfile> > GetAllAsync()
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entities = await context.ReferralLeadProfiles.ToListAsync();

                return(entities
                       .Select(o => ToDomain(_encryptionService.Decrypt(o)))
                       .ToList());
            }
        }
        public async Task AddAsync(ReferralStakeModel referralStakeModel, TransactionContext txContext = null)
        {
            using (var context = _contextFactory.CreateDataContext(txContext))
            {
                var entity = ReferralStakeEntity.Create(referralStakeModel);

                context.ReferralStakes.Add(entity);

                await context.SaveChangesAsync();
            }
        }
        public async Task InsertAsync(PaymentProcessedCallbackUrl contract)
        {
            using (var context = _msSqlContextFactory.CreateDataContext())
            {
                var entity = _mapper.Map <PaymentProcessedCallbackUrlEntity>(contract);

                context.Add(entity);

                await context.SaveChangesAsync();
            }
        }
        public async Task SaveTokensSnapshotAsync(DailyTokensSnapshot dailyTokensSnapshot)
        {
            var entity = DailyTokensSnapshotEntity.Create(dailyTokensSnapshot);

            using (var context = _contextFactory.CreateDataContext())
            {
                context.DailyTokensSnapshots.Add(entity);

                await context.SaveChangesAsync();
            }
        }
Example #25
0
        public async Task DeleteAsync(IEnumerable <Guid> partners, Guid burnRuleId)
        {
            using (var context = _msSqlContextFactory.CreateDataContext())
            {
                var entities = context.BurnRulePartners
                               .Where(p => partners.Any(g => g == p.PartnerId) && p.BurnRuleEntityId == burnRuleId);

                context.BurnRulePartners.RemoveRange(entities);

                await context.SaveChangesAsync();
            }
        }
Example #26
0
        public async Task CreateAsync(IPaymentProviderDetails model)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = PaymentProviderDetailsEntity.Create(model);
                entity = _encryptionService.Encrypt(entity);

                context.PaymentProviderDetails.Add(entity);

                await context.SaveChangesAsync();
            }
        }
        public async Task <Guid> InsertAsync(CampaignCompletion campaignCompletion)
        {
            using (var context = _msSqlContextFactory.CreateDataContext())
            {
                var entity = _mapper.Map <CampaignCompletionEntity>(campaignCompletion);

                context.Add(entity);

                await context.SaveChangesAsync();

                return(entity.Id);
            }
        }
Example #28
0
        public async Task InsertAsync(VoucherPurchasePaymentDto voucherPurchasePaymentOperation)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var historyEntity = TransactionHistoryEntity.CreateForVoucherTokenReservation(voucherPurchasePaymentOperation);
                var voucherPurchasePaymentEntity = new VoucherPurchasePaymentEntity(voucherPurchasePaymentOperation);

                context.VoucherPurchasePayments.Add(voucherPurchasePaymentEntity);
                context.TransactionHistories.Add(historyEntity);

                await context.SaveChangesAsync();
            }
        }
        public async Task <Guid> AddAsync(Guid id,
                                          string customerId,
                                          long nonce,
                                          string masterWalletAddress,
                                          OperationType type,
                                          string contextJson,
                                          DateTime createdAt,
                                          string transactionHash)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var operation = OperationEntity.Create(
                    id,
                    customerId,
                    masterWalletAddress,
                    nonce,
                    type,
                    contextJson,
                    createdAt,
                    transactionHash);

                await context.Operations.AddAsync(operation);

                await context.SaveChangesAsync();

                return(operation.Id);
            }
        }
        public async Task DeleteAsync(IEnumerable <EarnRuleContentModel> spendRuleContents)
        {
            using (var context = _msSqlContextFactory.CreateDataContext())
            {
                var entities = _mapper.Map <List <EarnRuleContentEntity> >(spendRuleContents);

                foreach (var entity in entities)
                {
                    context.EarnRuleContents.Remove(entity);
                }

                await context.SaveChangesAsync();
            }
        }