Esempio n. 1
0
        public static void AddAccounts(AppDbContext db)
        {
            Saving s1 = new Saving();

            s1.SavingsAccountNumber = 1000000001;
            s1.User           = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**");
            s1.SavingsName    = "William's Savings";
            s1.SavingsBalance = 40035.5m;
            db.SavingsDbSet.AddOrUpdate(s => s.SavingsAccountNumber, s1);

            StockPortfolio sp1 = new StockPortfolio(); sp1.StockAccountNumber = 1000000000; sp1.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); sp1.Name = "Shan's Stock"; sp1.PortfolioCashBalance = 0m; db.StockPortfoliosDbSet.AddOrUpdate(sp => sp.StockAccountNumber, sp1);
            Checking       c1  = new Checking(); c1.CheckingsAccountNumber = 1000000002; c1.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); c1.CheckingsName = "Gregory's Checking"; c1.CheckingsBalance = 39779.49m; db.CheckingsDbSet.AddOrUpdate(c => c.CheckingsAccountNumber, c1);
            Checking       c2  = new Checking(); c2.CheckingsAccountNumber = 1000000003; c2.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); c2.CheckingsName = "Allen's Checking"; c2.CheckingsBalance = 47277.33m; db.CheckingsDbSet.AddOrUpdate(c => c.CheckingsAccountNumber, c2);
            Checking       c3  = new Checking(); c3.CheckingsAccountNumber = 1000000004; c3.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); c3.CheckingsName = "Reagan's Checking"; c3.CheckingsBalance = 70812.15m; db.CheckingsDbSet.AddOrUpdate(c => c.CheckingsAccountNumber, c3);
            Saving         s2  = new Saving(); s2.SavingsAccountNumber = 1000000005; s2.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); s2.SavingsName = "Kelly's Savings"; s2.SavingsBalance = 21901.97m; db.SavingsDbSet.AddOrUpdate(s => s.SavingsAccountNumber, s2);
            Checking       c4  = new Checking(); c4.CheckingsAccountNumber = 1000000006; c4.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); c4.CheckingsName = "Eryn's Checking"; c4.CheckingsBalance = 70480.99m; db.CheckingsDbSet.AddOrUpdate(c => c.CheckingsAccountNumber, c4);
            Saving         s3  = new Saving(); s3.SavingsAccountNumber = 1000000007; s3.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); s3.SavingsName = "Jake's Savings"; s3.SavingsBalance = 7916.4m; db.SavingsDbSet.AddOrUpdate(s => s.SavingsAccountNumber, s3);
            StockPortfolio sp2 = new StockPortfolio(); sp2.StockAccountNumber = 1000000008; sp2.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); sp2.Name = "Michelle's Stock"; sp2.PortfolioCashBalance = 0m; db.StockPortfoliosDbSet.AddOrUpdate(sp => sp.StockAccountNumber, sp2);
            Saving         s4  = new Saving(); s4.SavingsAccountNumber = 1000000009; s4.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); s4.SavingsName = "Jeffrey's Savings"; s4.SavingsBalance = 69576.83m; db.SavingsDbSet.AddOrUpdate(s => s.SavingsAccountNumber, s4);
            StockPortfolio sp3 = new StockPortfolio(); sp3.StockAccountNumber = 1000000010; sp3.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); sp3.Name = "Kelly's Stock"; sp3.PortfolioCashBalance = 0m; db.StockPortfoliosDbSet.AddOrUpdate(sp => sp.StockAccountNumber, sp3);
            Checking       c5  = new Checking(); c5.CheckingsAccountNumber = 1000000011; c5.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); c5.CheckingsName = "Eryn's Checking 2"; c5.CheckingsBalance = 30279.33m; db.CheckingsDbSet.AddOrUpdate(c => c.CheckingsAccountNumber, c5);
            IRA            r1  = new IRA(); r1.IRAAccountNumber = 1000000012; r1.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); r1.IRAName = "Jennifer's IRA"; r1.IRACashBalance = 5000m; db.IRAsDbSet.AddOrUpdate(r => r.IRAAccountNumber, r1);
            Saving         s5  = new Saving(); s5.SavingsAccountNumber = 1000000013; s5.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); s5.SavingsName = "Sarah's Savings"; s5.SavingsBalance = 11958.08m; db.SavingsDbSet.AddOrUpdate(s => s.SavingsAccountNumber, s5);
            Saving         s6  = new Saving(); s6.SavingsAccountNumber = 1000000014; s6.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); s6.SavingsName = "Jeremy's Savings"; s6.SavingsBalance = 72990.47m; db.SavingsDbSet.AddOrUpdate(s => s.SavingsAccountNumber, s6);
            Saving         s7  = new Saving(); s7.SavingsAccountNumber = 1000000015; s7.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); s7.SavingsName = "Elizabeth's Savings"; s7.SavingsBalance = 7417.2m; db.SavingsDbSet.AddOrUpdate(s => s.SavingsAccountNumber, s7);
            IRA            r2  = new IRA(); r2.IRAAccountNumber = 1000000016; r2.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); r2.IRAName = "Allen's IRA"; r2.IRACashBalance = 5000m; db.IRAsDbSet.AddOrUpdate(r => r.IRAAccountNumber, r2);
            StockPortfolio sp4 = new StockPortfolio(); sp4.StockAccountNumber = 1000000017; sp4.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); sp4.Name = "John's Stock"; sp4.PortfolioCashBalance = 0m; db.StockPortfoliosDbSet.AddOrUpdate(sp => sp.StockAccountNumber, sp4);
            Saving         s8  = new Saving(); s8.SavingsAccountNumber = 1000000018; s8.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); s8.SavingsName = "Clarence's Savings"; s8.SavingsBalance = 1642.82m; db.SavingsDbSet.AddOrUpdate(s => s.SavingsAccountNumber, s8);
            Checking       c6  = new Checking(); c6.CheckingsAccountNumber = 1000000019; c6.User = db.Users.FirstOrDefault(u => u.UserName == "*****@*****.**"); c6.CheckingsName = "Sarah's Checking"; c6.CheckingsBalance = 84421.45m; db.CheckingsDbSet.AddOrUpdate(c => c.CheckingsAccountNumber, c6);
        }
Esempio n. 2
0
        public void SetUp()
        {
            this._startDate = new DateTime(2017, 2, 11);

            this._downloadService = new DownloaderService(
                null,
                new YahooFinanceDataSource(),
                new GoogleFinanceDataSource(),
                new MorningStarDataSource());

            this._stock = new Stock
            {
                Country = new Singapore(),
                Symbol  = "S63"
            };

            this._portfolio = new StockPortfolio(this._startDate, 50000);

            var callingAssemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var aggCatalog = new AggregateCatalog();

            aggCatalog.Catalogs.Add(new DirectoryCatalog(callingAssemblyLocation ?? throw new InvalidOperationException(), "twentySix.*.dll"));
            var compositionContainer = new CompositionContainer(aggCatalog);

            ApplicationHelper.StartUp(new LoggingService(), compositionContainer);
        }
Esempio n. 3
0
        public ActionResult SellStock(SellStockViewModel model, int StockPurchaseID)
        {
            AppUser        user           = db.Users.Find(User.Identity.GetUserId());
            StockPortfolio stockPortfolio = user.StockPortfolio;

            model.stockPortfolioID = stockPortfolio.StockPortfolioID;
            if (ModelState.IsValid)
            {
                StockPurchase stockPurchase = db.StockPurchases.Find(StockPurchaseID);
                if (model.NumberOfSharesToSell > stockPurchase.NumberOfShares)
                {
                    return(View("Error", new string[] { "You can't sell more shares than what you have." }));
                }
                if (model.NumberOfSharesToSell == 0)
                {
                    return(View("Error", new string[] { "Why are you trying to sell 0 shares...?" }));
                }
                if (model.NumberOfSharesToSell < 0)
                {
                    return(View("Error", new string[] { "You can't sell a negative number of shares." }));
                }

                model.stockPurchaseID         = StockPurchaseID;
                model.StockName               = stockPurchase.Stock.StockName;
                model.SellDate                = DateTime.Now;
                model.NumberOfSharesToSell    = model.NumberOfSharesToSell;
                model.NumberOfSharesRemaining = stockPurchase.NumberOfShares - model.NumberOfSharesToSell;
                model.Fees        = stockPurchase.Stock.Fee;
                model.NetGainLoss = (stockPurchase.Stock.CurrentPrice * model.NumberOfSharesToSell) - (stockPurchase.InitialSharePrice * model.NumberOfSharesToSell);
                return(RedirectToAction("SellStockSummaryPage", model));
            }

            ViewBag.CustomerStockPurchases = GetCustomerStockPurchases();
            return(View(model));
        }
Esempio n. 4
0
        //POST: StockPortfolios/Deposit
        public ActionResult Deposit([Bind(Include = "TransactionID,TransactionDate,Amount,Description")] Transaction transaction)
        {
            if (ModelState.IsValid)
            {
                transaction.TransactionType  = "Deposit";
                transaction.isBeingDisputed  = false;
                transaction.EmployeeComments = "";
                StockPortfolio StockPortfolioToChange = GetStockPortfolio();
                if (transaction.Amount > 5000)
                {
                    transaction.isPending = true;
                }
                else
                {
                    transaction.isPending = false;
                    StockPortfolioToChange.CashValueBalance += transaction.Amount;
                }
                if (transaction.Description == null)
                {
                    transaction.Description = "";
                }
                transaction.StockPortfolioAffected = StockPortfolioToChange;
                StockPortfolioToChange.Transactions.Add(transaction);
                db.Transactions.Add(transaction);
                db.SaveChanges();
                return(RedirectToAction("MyBankAccounts", "Account"));
            }

            return(View(transaction));
        }
Esempio n. 5
0
        public ActionResult Withdrawal([Bind(Include = "TransactionID,TransactionDate,Amount,Description")] Transaction transaction)
        {
            if (ModelState.IsValid)
            {
                transaction.TransactionType  = "Withdrawal";
                transaction.isBeingDisputed  = false;
                transaction.EmployeeComments = "";
                transaction.isPending        = false;
                if (transaction.Description == null)
                {
                    transaction.Description = "";
                }
                StockPortfolio StockPortfolioToChange = GetStockPortfolio();
                if (StockPortfolioToChange.CashValueBalance < 0)
                {
                    return(View("Error", new string[] { "You can't withdraw from an overdrawn account." }));
                }
                if (transaction.Amount > StockPortfolioToChange.CashValueBalance)
                {
                    return(View("Error", new string[] { "You don't have enough funds to withdraw that much money." }));
                }
                StockPortfolioToChange.CashValueBalance -= transaction.Amount;
                transaction.StockPortfolioAffected       = StockPortfolioToChange;
                StockPortfolioToChange.Transactions.Add(transaction);
                db.Transactions.Add(transaction);
                db.SaveChanges();
                return(RedirectToAction("MyBankAccounts", "Account"));
            }

            return(View(transaction));
        }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "StockPortfolioID,AccountNum,AccountName,Balance,Disabled")] StockPortfolio stockPortfolio)
        {
            if (ModelState.IsValid)
            {
                if (stockPortfolio.Balance < 0)
                {
                    return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: Your starting balance must be positive.'); window.location='../StockPortfolio/Create';</script>"));
                }
                AppUser user = db.Users.Find(User.Identity.GetUserId());

                Transaction t = new Transaction();
                t.Date        = DateTime.Today;
                t.ToAccount   = stockPortfolio.AccountNum;
                t.TransType   = TransType.Deposit;
                t.Description = "Initial deposit";
                t.Amount      = stockPortfolio.Balance;
                if (stockPortfolio.Balance > 5000)
                {
                    stockPortfolio.Balance = 0;
                    t.NeedsApproval        = true;
                }

                stockPortfolio.Transactions = new List <Transaction>();
                stockPortfolio.Transactions.Add(t);

                user.StockPortfolio = new StockPortfolio();
                user.StockPortfolio = stockPortfolio;

                db.SaveChanges();
                return(RedirectToAction("Home", "Customer"));
            }

            //TODO: ** Add task to be approved by manager
            return(View(stockPortfolio));
        }
Esempio n. 7
0
        public ActionResult Create([Bind(Include = "StockPortfolioID,AccountNumber,CashBalance,Name,InitialDeposit")] StockPortfolio stockPortfolio)
        {
            //assign user
            stockPortfolio.User = db.Users.Find(User.Identity.GetUserId());


            //assign account number
            stockPortfolio.AccountNumber = AccountUtitlities.SetAccountNumber(db);

            //assign defualt name if left blank
            if (stockPortfolio.Name == null)
            {
                stockPortfolio.Name = AccountUtitlities.NullName(stockPortfolio);
            }

            //put initial deposit in cash balance
            stockPortfolio.CreateStockPortfolio();

            //NOTE: there's an error with model state
            if (ModelState.IsValid)
            {
                db.Portfolios.Add(stockPortfolio);
                db.SaveChanges();
                return(RedirectToAction("Index", "StockPortfolios"));
            }



            return(View(stockPortfolio));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,ApplicationUserId,Name")] StockPortfolio stockPortfolio)
        {
            if (id != stockPortfolio.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(stockPortfolio);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StockPortfolioExists(stockPortfolio.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }

            return(View(stockPortfolio));
        }
Esempio n. 9
0
        public ActionResult EditName(String id)
        {
            if (db.Users.Find(User.Identity.GetUserId()).Disabled == true)
            {
                return(Content("<script language'javascript' type = 'text/javascript'> alert('Access Denied: Your account has been disabled. You are in a view-only mode.'); window.location='../Customer/Home';</script>"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StockPortfolio stockPortfolio = db.StockPortfolios.Find(id);

            if (stockPortfolio == null)
            {
                return(HttpNotFound());
            }

            ViewBag.AccountID = id;
            EditAccountNameViewModel editAccountNameVM = new EditAccountNameViewModel();

            editAccountNameVM.AccountName = stockPortfolio.AccountName;

            return(View(editAccountNameVM));
        }
Esempio n. 10
0
        public List <StockViewModel> GetAcctStocks()
        {
            List <StockViewModel> acctStock = new List <StockViewModel>();

            //Get the ID for the user who is currently logged in
            UserManager <AppUser> userManager = new UserManager <AppUser>(new UserStore <AppUser>(db));
            var user = userManager.FindById(User.Identity.GetUserId());
            //Find the portfolio belonging to this user
            StockPortfolio portfolio = user.StockPortfolio;

            List <StockViewModel> listViewModels = new List <StockViewModel>();

            //add all the stocks in the user's portfolio to the list of stockviewmodels
            foreach (StockDetail s in portfolio.StockDetails)
            {
                StockViewModel viewModel = new StockViewModel();
                viewModel.CurrentPrice  = bevo.Utilities.GetQuote.GetStock(s.Stock.StockTicker).LastTradePrice;
                viewModel.Name          = s.Stock.StockName;
                viewModel.Type          = s.Stock.TypeOfStock;
                viewModel.NumInAccount  = s.Quantity;
                viewModel.Ticker        = s.Stock.StockTicker;
                viewModel.PurchasePrice = 10.00m;
                viewModel.StockID       = s.Stock.StockID;
                listViewModels.Add(viewModel);
            }


            return(listViewModels);
        }
        /// <summary>
        /// it will read all the stocks Data
        /// </summary>
        /// <param name="stockPortfolio"></param>
        /// <returns></returns>
        public static List <StockPortfolio> ReadStockData(StockPortfolio stockPortfolio)
        {
            try
            {
                List <StockPortfolio> stockPortfolios = StockAccount.ListOfCompanyShares();

                if (stockPortfolios != null)
                {
                    foreach (StockPortfolio stockPortfolio1 in stockPortfolios)
                    {
                        if (stockPortfolio1.ShareName.Equals(stockPortfolio.ShareName))
                        {
                            stockPortfolio1.NoOfShare = stockPortfolio.NoOfShare;
                            return(stockPortfolios);
                        }
                    }
                }

                return(null);
            }
            catch (Exception e)
            {
                Console.WriteLine("Message: {0}", e.Message);
                return(null);
            }
        }
Esempio n. 12
0
        public StockPortfolio GetStockPortfolio()
        {
            AppUser        user           = db.Users.Find(User.Identity.GetUserId());
            StockPortfolio stockPortfolio = user.StockPortfolio;

            return(stockPortfolio);
        }
        public static string NullName(StockPortfolio portfolio)
        {
            string name;

            name = portfolio.User.FName + "'s stock portfolio";

            return(name);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            StockPortfolio stockPortfolio = db.StockPortfoliosDbSet.Find(id);

            db.StockPortfoliosDbSet.Remove(stockPortfolio);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 15
0
        public ActionResult ApproveStockPortfolio(int?id)
        {
            StockPortfolio stockPortfolio = db.StockPortfolios.Find(id);

            stockPortfolio.isPending = false;
            db.SaveChanges();
            return(RedirectToAction("EmployeePortal", "Manage"));
        }
        public ActionResult CanBuy(int SelectedID)
        {
            StockPortfolio stockToChange = db.StockPortfolios.Find(SelectedID);

            stockToChange.CanBuy          = true;
            db.Entry(stockToChange).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("CanBuy"));
        }
 public ActionResult Edit([Bind(Include = "StockPortfolioID,StockAccountNumber,CashBalance,Name")] StockPortfolio stockPortfolio)
 {
     if (ModelState.IsValid)
     {
         db.Entry(stockPortfolio).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(stockPortfolio));
 }
Esempio n. 18
0
 public ActionResult Edit(StockPortfolio stockPortfolio)
 {
     if (ModelState.IsValid)
     {
         db.Entry(stockPortfolio).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("MyBankAccounts", "Account"));
     }
     return(View(stockPortfolio));
 }
Esempio n. 19
0
        public List <AccountsViewModel> GetListAccounts()
        {
            AppUser user = db.Users.Find(User.Identity.GetUserId());
            List <AccountsViewModel> allAccounts = new List <AccountsViewModel>();

            if (user.CheckingAccounts != null)
            {
                List <CheckingAccount> checkingAccounts = user.CheckingAccounts.ToList <CheckingAccount>();
                // get checkings
                foreach (var c in checkingAccounts)
                {
                    AccountsViewModel accountToAdd = new AccountsViewModel();
                    accountToAdd.AccountNum  = c.AccountNum;
                    accountToAdd.AccountName = c.AccountName;
                    accountToAdd.Balance     = c.Balance;
                    allAccounts.Add(accountToAdd);
                }
            }

            if (user.IRAccount != null)
            {
                IRAccount i = user.IRAccount;
                // get checkings
                AccountsViewModel accountToAdd = new AccountsViewModel();
                accountToAdd.AccountNum  = i.AccountNum;
                accountToAdd.AccountName = i.AccountName;
                accountToAdd.Balance     = i.Balance;
                allAccounts.Add(accountToAdd);
            }

            if (user.SavingAccounts != null)
            {
                List <SavingAccount> savingAccounts = user.SavingAccounts.ToList <SavingAccount>();
                // get savings
                foreach (var s in savingAccounts)
                {
                    AccountsViewModel accountToAdd = new AccountsViewModel();
                    accountToAdd.AccountNum  = s.AccountNum;
                    accountToAdd.AccountName = s.AccountName;
                    accountToAdd.Balance     = s.Balance;
                    allAccounts.Add(accountToAdd);
                }
            }
            if (user.StockPortfolio != null)
            {
                StockPortfolio stockPortfolio = user.StockPortfolio;
                // get cash portion stock portfolio
                AccountsViewModel p = new AccountsViewModel();
                p.AccountNum  = stockPortfolio.AccountNum;
                p.AccountName = stockPortfolio.AccountName;
                p.Balance     = stockPortfolio.Balance;
                allAccounts.Add(p);
            }
            return(allAccounts);
        }
Esempio n. 20
0
 public ActionResult EditName([Bind(Include = "AccountName")] EditAccountNameViewModel vm, String id)
 {
     if (ModelState.IsValid)
     {
         StockPortfolio stockPortfolio = db.StockPortfolios.Find(id);
         stockPortfolio.AccountName = vm.AccountName;
         db.SaveChanges();
         return(RedirectToAction("Details", new { id = id }));
     }
     return(View(vm));
 }
        public ActionResult Create([Bind(Include = "StockPortfolioID,StockAccountNumber,CashBalance,Name")] StockPortfolio stockPortfolio)
        {
            if (ModelState.IsValid)
            {
                db.StockPortfoliosDbSet.Add(stockPortfolio);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(stockPortfolio));
        }
Esempio n. 22
0
        //GET: StockPortfolios/SellStock
        public ActionResult SellStock()
        {
            AppUser            user           = db.Users.Find(User.Identity.GetUserId());
            StockPortfolio     stockPortfolio = user.StockPortfolio;
            SellStockViewModel model          = new SellStockViewModel {
                stockPortfolioID = stockPortfolio.StockPortfolioID
            };

            ViewBag.CustomerStockPurchases = GetCustomerStockPurchases();
            return(View(model));
        }
        public async Task <IActionResult> Create([Bind("Id,ApplicationUserId,Name")] StockPortfolio stockPortfolio)
        {
            if (ModelState.IsValid)
            {
                _context.Add(stockPortfolio);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            //ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", stockPortfolio.ApplicationUserId);
            return(View(stockPortfolio));
        }
Esempio n. 24
0
        private void ResetTrainingSession()
        {
            Portfolio = new StockPortfolio(_settings.StartDate, _settings.InitialCash);

            TrainingSession = new TrainingSession(Portfolio, Stock)
            {
                TrainSamplePercentage       = _settings.PercentageTraining,
                NumberAnns                  = _settings.NumberANNs,
                NumberHiddenLayers          = _settings.NumberHiddenLayers,
                NumberNeuronsPerHiddenLayer = _settings.NumberNeuronsHiddenLayer
            };
        }
        public String GetAccountType(Int32?accountNum)
        {
            AppUser user = db.Users.Find(User.Identity.GetUserId());
            String  accountType;

            List <CheckingAccount> checkingAccounts = user.CheckingAccounts;

            foreach (var c in checkingAccounts)
            {
                if (accountNum == c.AccountNum)
                {
                    accountType = "CHECKING";
                    return(accountType);
                }
            }

            List <SavingAccount> savingAccounts = user.SavingAccounts;

            foreach (var s in savingAccounts)
            {
                if (accountNum == s.AccountNum)
                {
                    accountType = "SAVING";
                    return(accountType);
                }
            }

            IRAccount iraAccount = user.IRAccount;

            if (iraAccount != null)
            {
                if (accountNum == iraAccount.AccountNum)
                {
                    accountType = "IRA";
                    return(accountType);
                }
            }


            StockPortfolio stockPortfolio = user.StockPortfolio;

            if (stockPortfolio != null)
            {
                if (accountNum == stockPortfolio.AccountNum)
                {
                    accountType = "STOCKPORTFOLIO";
                    return(accountType);
                }
            }

            return("NOT FOUND");
        }
        public ActionResult Edit([Bind(Include = "TransactionID,TypeOfTransaction,ApprovalStatus,TransactionDate,TransactionAmount,TransactionDescription,TransactionComments,DisputeStatus,AccountSender,AccountSenderID")] Transaction transaction, string TransactionDate, string SelectedAccountType, int?Id, int?AccountNumber, TransactionStatus?ApprovalStatus, Int32 AccountID, String UserEmail)
        {
            if (ModelState.IsValid)
            {
                db.Entry(transaction).State = EntityState.Modified;
                db.SaveChanges();

                if (ApprovalStatus == TransactionStatus.Approved)
                {
                    Checking accountToChange1 = db.Checkings.Find(transaction.AccountSenderID);
                    if (accountToChange1 != null && accountToChange1.CheckingNumber == transaction.AccountSender)
                    {
                        accountToChange1.CheckingBalance += transaction.TransactionAmount;
                        db.Entry(accountToChange1).State  = EntityState.Modified;
                        db.SaveChanges();
                        EmailSender(UserEmail, accountToChange1.CheckingNumber, transaction.TransactionAmount);
                    }

                    Savings accountToChange2 = db.Savings.Find(transaction.AccountSenderID);
                    if (accountToChange2 != null && accountToChange2.SavingsNumber == transaction.AccountSender)
                    {
                        accountToChange2.SavingsBalance += transaction.TransactionAmount;
                        db.Entry(accountToChange2).State = EntityState.Modified;
                        db.SaveChanges();
                        EmailSender(UserEmail, accountToChange2.SavingsNumber, accountToChange2.SavingsBalance);
                    }

                    IRA accountToChange3 = db.IRAs.Find(transaction.AccountSenderID);
                    if (accountToChange3 != null && accountToChange3.IRANumber == transaction.AccountSender)
                    {
                        accountToChange3.IRABalance     += transaction.TransactionAmount;
                        db.Entry(accountToChange3).State = EntityState.Modified;
                        db.SaveChanges();
                        EmailSender(UserEmail, accountToChange3.IRANumber, accountToChange3.IRABalance);
                    }

                    StockPortfolio accountToChange4 = db.StockPortfolios.Find(transaction.AccountSenderID);
                    if (accountToChange4 != null && accountToChange4.StockPortfolioNumber == transaction.AccountSender)
                    {
                        accountToChange4.CashBalance    += transaction.TransactionAmount;
                        db.Entry(accountToChange4).State = EntityState.Modified;
                        db.SaveChanges();
                        EmailSender(UserEmail, accountToChange4.StockPortfolioNumber, Convert.ToDecimal(accountToChange4.CashBalance));
                    }
                }


                return(RedirectToAction("Index"));
            }
            ViewBag.TransactionID = new SelectList(db.Disputes, "DisputeID", "Comments", transaction.TransactionID);
            return(View(transaction));
        }
        // GET: StockPortfolios/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StockPortfolio stockPortfolio = db.StockPortfoliosDbSet.Find(id);

            if (stockPortfolio == null)
            {
                return(HttpNotFound());
            }
            return(View(stockPortfolio));
        }
Esempio n. 28
0
        public bool OverdraftStatus()
        {
            // get all accounts
            // check if overdrafted
            bool isOverdraft = false;

            List <CheckingAccount> checkingAccounts = GetAllCheckingAccts();

            foreach (CheckingAccount c in checkingAccounts)
            {
                if (c.Balance < 0)
                {
                    isOverdraft = true;
                }
            }

            List <SavingAccount> savingAccounts = GetAllSavingAccts();

            foreach (SavingAccount s in savingAccounts)
            {
                if (s.Balance < 0)
                {
                    isOverdraft = true;
                }
            }

            IRAccount irAccount = GetIRAccount();

            if (irAccount != null)
            {
                if (irAccount.Balance < 0)
                {
                    isOverdraft = true;
                }
            }

            StockPortfolio portfolio = GetStockPortfolio();

            if (portfolio != null)
            {
                if (portfolio.Balance < 0)
                {
                    isOverdraft = true;
                }
            }


            return(isOverdraft);
        }
Esempio n. 29
0
        public async Task <bool> CreateStockPortfolio(StockPortfolioCreate model)
        {
            var entity = new StockPortfolio()
            {
                AuthorId    = _userId,
                StockId     = model.StockId,
                PortfolioId = model.PortfolioId
            };

            using (var ctx = new ApplicationDbContext())
            {
                var query = ctx.StockPortfolios.Add(entity);
                return(await ctx.SaveChangesAsync() == 1);
            }
        }
Esempio n. 30
0
        public ActionResult CheckAccounts()
        {
            AppUser user = db.Users.Find(User.Identity.GetUserId());
            List <CheckingAccount> checkingAccounts = user.CheckingAccounts.ToList();
            List <SavingAccount>   savingAccounts   = user.SavingAccounts.ToList();
            IRAccount      irAccount      = user.IRAccount;
            StockPortfolio stockPortfolio = user.StockPortfolio;

            if (checkingAccounts.Count() == 0 && savingAccounts.Count() == 0 && irAccount == null && stockPortfolio == null)
            {
                return(RedirectToAction("ChooseAccount", "Account"));
            }

            else
            {
                return(RedirectToAction("Home"));
            }
        }