Exemplo n.º 1
0
        public void Setup()
        {
            Database.SetInitializer <ApplicationDbContext>(null);

            var config = new MapperConfiguration(cfg => {
                cfg.CreateMap <VintageDto, VintageViewModel>().ReverseMap();
            });

            mapper = config.CreateMapper();

            db      = new ApplicationDbContext();
            manager = new ApplicationUserManager(new CustomUserStore(db),
                                                 new DataProtectionProviderFactory(() => null));
            var confRepo = new ConfRepo(db);

            gzTransactionRepo = new GzTransactionRepo(db, confRepo);
            userRepo          = new UserRepo(db);
            custPortfolioRepo = new UserPortfolioRepo(db, confRepo, userRepo);
            invBalanceRepo    = new InvBalanceRepo(
                db,
                new UserPortfolioSharesRepo(db),
                gzTransactionRepo,
                custPortfolioRepo,
                confRepo,
                userRepo
                );

            db = CreateInvestmentsApiController(out investmentsApiController);
        }
Exemplo n.º 2
0
Arquivo: Seed.cs Projeto: blewater/gz
        private static void UpsDbInvBalances(ApplicationDbContext context, int custId)
        {
            // Put fake amounts for gaming balances that are null
            context.Database.ExecuteSqlCommand("Update InvBalances Set BegGmBalance = 3000, Deposits = 3000, Withdrawals = 1000, GmGainLoss = -2000, EndGmBalance = 3000 Where BegGmBalance is NUll OR Deposits is Null OR Withdrawals is Null OR GmGainLoss is NUll OR EndGmBalance is NUll");

            var confRepo          = new ConfRepo(context);
            var userRepo          = new UserRepo(context);
            var custPortfolioRepo = new UserPortfolioRepo(context, confRepo, userRepo);
            var invB = new
                       InvBalanceRepo(
                context,
                new UserPortfolioSharesRepo(context),
                new GzTransactionRepo(context, confRepo),
                custPortfolioRepo,
                confRepo,
                userRepo
                );

            var nowUtc            = DateTime.UtcNow;
            var startYearMonthStr = nowUtc.AddMonths(-6).ToStringYearMonth();
            var endYeerMonthStr   = nowUtc.ToStringYearMonth();

            var balance      = 1000M;
            var totalCashInv = 1000m;

            while (startYearMonthStr.BeforeEq(endYeerMonthStr))
            {
                var gain = balance * 0.06M;
                invB.UpsInvBalance(
                    custId,
                    RiskToleranceEnum.Medium,
                    int.Parse(startYearMonthStr.Substring(4)),
                    int.Parse(startYearMonthStr.Substring(4, 2)),
                    1000M,
                    balance,
                    gain,
                    0m,
                    1m,
                    0m,
                    3000m,
                    3000m,
                    1000m,
                    -2000M,
                    3000m,
                    // Assume no sold vintages
                    totalCashInv,
                    totalCashInv,
                    0m,
                    nowUtc);

                startYearMonthStr = DbExpressions.AddMonth(startYearMonthStr);
                // 6%
                balance       = balance + balance * 1.06m;
                totalCashInv += 1000m;
            }
        }
Exemplo n.º 3
0
Arquivo: Seed.cs Projeto: blewater/gz
        private static void CreateUpdUserPortfolioSelection(ApplicationDbContext context, int custId)
        {
            var confRepo          = new ConfRepo(context);
            var custPortfolioRepo =
                new UserPortfolioRepo(
                    context,
                    confRepo,
                    new UserRepo(context));

            custPortfolioRepo.SetDbUserMonthsPortfolioMix(custId, RiskToleranceEnum.Low, 2015, 1, new DateTime(2015, 1, 1));
        }
Exemplo n.º 4
0
        public void Setup()
        {
            Database.SetInitializer <ApplicationDbContext>(null);

            db = new ApplicationDbContext();
            devDbConnString = ConfigurationManager.ConnectionStrings["gzDevDb"].ConnectionString;
            var confRepo = new ConfRepo(db);

            gzTrx = new GzTransactionRepo(db, confRepo);
            var userRepo = new UserRepo(db);

            cpRepo     = new UserPortfolioRepo(db, confRepo, userRepo);
            invBalRepo = new InvBalanceRepo(db, new UserPortfolioSharesRepo(db), gzTrx, cpRepo, confRepo, userRepo);
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// Cache global database data applicable to all customers
        ///
        /// </summary>
        private void CacheGlobalData()
        {
            try {
                //-------- Global Caching Configuration of Single GzConfiguration Row
                var db = new ApplicationDbContext();

                // Cache configuration object
                var _ = new ConfRepo(db).GetConfRow();

                //-------- Cache Fund prices for 2 hours
                var __ = db.PortfolioPrices
                         .Where(p => p.YearMonthDay == db.PortfolioPrices.Select(pm => pm.YearMonthDay).Max())
                         .Select(p => new {
                    p.PortfolioLowPrice,
                    p.PortfolioMediumPrice,
                    p.PortfolioHighPrice,
                    p.YearMonthDay
                })
                         .FromCache(DateTime.UtcNow.AddHours(2));
            }
            catch (Exception ex) {
                _logger.Error(ex, "CacheGlobalData()");
            }
        }