protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (dbContext == null)
         {
             dbContext.Dispose();
             dbContext = null;
         }
     }
 }
Example #2
0
 public MockFundraiserRepository(FundContext dbContext)
 {
     Fundraisers = new List <Fundraiser> {
         new Fundraiser {
             Id = Guid.NewGuid(), Name = "Pauls Extension", Amount = 10000, CreatedDate = DateTimeOffset.Now.AddDays(-3)
         },
         new Fundraiser {
             Id = Guid.NewGuid(), Name = "Joes Preop", Amount = 23000, CreatedDate = DateTimeOffset.Now
         },
         new Fundraiser {
             Id = Guid.NewGuid(), Name = "Big party!", Amount = 10000, CreatedDate = DateTimeOffset.Now
         },
     };
 }
Example #3
0
 public MockDonorRepository(FundContext context)
 {
     Donors = new List <Donor> {
         new Donor {
             Id = Guid.NewGuid(), Name = "Marcus", CreatedDate = DateTimeOffset.Now.AddDays(-30)
         },
         new Donor {
             Id = Guid.NewGuid(), Name = "Eliza", CreatedDate = DateTimeOffset.Now
         },
         new Donor {
             Id = Guid.NewGuid(), Name = "Camille", CreatedDate = DateTimeOffset.Now.AddDays(-3)
         },
     };
 }
        public async Task PopulateAll(FundContext db)
        {
            var query = db.Transactions
                        .Where(x => x.DonorTransactionSource.TransactionSourceIdentifier == _donorTransactionSource)
                        .OrderByDescending(x => x.TransactionDateTimeUtc);

            var items = await query
                        .Skip(Offset)
                        .Take(Count)
                        .ToListAsync();

            Total = await query.CountAsync();

            Items = items
                    .Select(DonorTransactionModel.FromEntity)
                    .ToList();
        }
        public TransactionGeneratorService(IServiceProvider serviceProvider)
        {
            _serviceScope = serviceProvider.CreateScope();
            var loggerFactory = _serviceScope.ServiceProvider.GetServiceOrThrow <ILoggerFactory>();

            _logger = loggerFactory.GetLogger <TransactionGeneratorService>();
            _transactionFeedService = _serviceScope.ServiceProvider.GetService(typeof(IIntegrationEventQueue)) as IIntegrationEventQueue;
            _db        = _serviceScope.ServiceProvider.GetService(typeof(FundContext)) as FundContext;
            _merchants = new Dictionary <Guid, string>()
            {
                { Guid.NewGuid(), "Merchant 1" },
                { Guid.NewGuid(), "Merchant 2" },
                { Guid.NewGuid(), "Merchant 3" },
                { Guid.NewGuid(), "Merchant 4" },
                { Guid.NewGuid(), "Merchant 5" },
                { Guid.NewGuid(), "Merchant 6" },
                { Guid.NewGuid(), "Merchant 7" },
                { Guid.NewGuid(), "Merchant 8" },
                { Guid.NewGuid(), "Merchant 9" },
                { Guid.NewGuid(), "Merchant 10" }
            };
        }
Example #6
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new FundContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <FundContext> >()))
            {
                // Look for any movies.
                if (context.Funds.Any())
                {
                    return;   // DB has been seeded
                }

                var httpClientFactory = serviceProvider.GetRequiredService <IHttpClientFactory>();
                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

                foreach (var fund in RunCrawler(httpClientFactory).Result)
                {
                    context.Funds.AddRange(fund);
                }

                context.SaveChanges();
            }
        }
        public MockDonationRepository(FundContext dbContext,
                                      IFundraiserRepository fundraiserRepository,
                                      IDonorRepository donorRepository)
        {
            this.dbContext            = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
            this.fundraiserRepository = fundraiserRepository ?? throw new ArgumentNullException(nameof(fundraiserRepository));
            this.donorRepository      = donorRepository ?? throw new ArgumentNullException(nameof(donorRepository));

            Donations = new List <Donation> {
                new Donation {
                    FundraiserId = fundraiserRepository.GetFundraisersAsync().Result.First().Id,
                    DonorId      = donorRepository.GetDonorsAsync().Result.First().Id,
                    Amount       = 10,
                    DonationDate = DateTimeOffset.Now
                },

                new Donation {
                    FundraiserId = fundraiserRepository.GetFundraisersAsync().Result.First().Id,
                    DonorId      = donorRepository.GetDonorsAsync().Result.Last().Id,
                    Amount       = 40,
                    DonationDate = DateTimeOffset.Now
                },
            };
        }
 public FundController(FundContext context, IWalletController walletController)
 {
     _context          = context;
     _walletController = walletController;
 }
Example #9
0
 public RemoveDonorTransactionSourceEventHandler(FundContext context)
 {
     _context = context;
 }
 public TransactionEventHandler(FundContext fundContext, IIntegrationEventQueue queue)
 {
     _fundContext = fundContext;
     _queue       = queue;
 }
Example #11
0
 public FundsController(FundContext context)
 {
     _context = context;
 }
 public TransactionsController(FundContext fundContext)
 {
     _fundContext = fundContext;
 }