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);
        }
Example #2
0
File: Seed.cs Project: 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;
            }
        }
Example #3
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);
        }