// GET: BankAccounts/Details/5
        public async Task <IActionResult> Details(int?id, BankAccountDetailsTab tab = BankAccountDetailsTab.AccountOperations)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            var         userId      = User.GetUserId();
            BankAccount bankAccount = await _context.BankAccounts
                                      .Include(a => a.Operations)
                                      .SingleAsync(m => m.Id == id && m.UserId == userId);

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

            var statements = tab == BankAccountDetailsTab.UploadedStatements
                ? await _context.AccountStatements.Where(s => s.BankAccountId == bankAccount.Id).ToArrayAsync()
                : null;

            var viewModel = new BankAccountDetailsViewModel(bankAccount, tab, statements);

            return(View(viewModel));
        }
        public BankAccountDetailsViewModel GetViewModel(Model.BankAccount bankAccount, CurrencyLogic currencyLogic)
        {
            var viewModel = new BankAccountDetailsViewModel()
            {
                Id       = bankAccount.Id,
                Name     = bankAccount.Name,
                Balance  = bankAccount.Balance,
                Currency = currencyLogic.GetCurrencyIconById(bankAccount.Currency),
                User     = bankAccount.User,
                SelectedItemsForPageId = 1
            };

            return(viewModel);
        }
예제 #3
0
 public ActionResult Details(BankAccountDetailsViewModel BankAccountDetailsViewModel)
 {
     return(RedirectToAction
                ("Details", "BankAccount",
                new {
         BankAccountID = BankAccountDetailsViewModel.BankAccountID,
         Description = BankAccountDetailsViewModel.DescriptionFilter,
         TransactionID = BankAccountDetailsViewModel.TransactionID,
         TransactionType = BankAccountDetailsViewModel.TransactionType,
         AmountLowerBound = BankAccountDetailsViewModel.AmountLowerBound,
         AmountUpperBound = BankAccountDetailsViewModel.AmountUpperBound,
         DateLowerBound = BankAccountDetailsViewModel.DateLowerBound,
         DateUpperBound = BankAccountDetailsViewModel.DateUpperBound,
     }));
 }
예제 #4
0
        //GET: BankAccount DETAILS
        public ActionResult Details(int id)
        {
            var model   = new BankAccountDetailsViewModel();
            var account = _manager.Get(id);

            model.Id           = account.Id;
            model.Name         = account.Name;
            model.Balance      = account.Balance;
            model.Transactions = account.Transactions.ToList().Select(t => new TransactionViewModel
            {
                Id           = t.Id,
                Date         = t.Date,
                Amount       = t.Amount,
                Description  = t.Description,
                CategoryName = t.Category.Name,
                CategoryId   = t.CategoryId,
                Type         = t.Type,
                IsReconciled = t.IsReconciled
            }).ToList();
            return(View(model));
        }
예제 #5
0
        //search
        public ActionResult Details(String BankAccountID, String TransactionID, String Description, TransactionTypeEnum?TransactionType, Decimal?AmountLowerBound, Decimal?AmountUpperBound, DateTime?DateLowerBound, DateTime?DateUpperBound)
        {
            List <Transaction> SelectedTransactions = new List <Transaction>();

            // Query for given bank account ID
            var accounts = from a in db.BankAccounts
                           where a.BankAccountID.Equals(BankAccountID)
                           select a;

            // If it doesn't exist, return 404
            if (accounts.Count() == 0)
            {
                return(RedirectToAction("Error", "Home", new { ErrorMessage = "Account does not exist." }));
            }
            BankAccount BankAccount = accounts.First();

            // Ensure it belongs to current user
            string UserId = System.Web.HttpContext.Current.User.Identity.GetUserId();

            if (BankAccount.UserID != UserId)
            {
                if (!User.IsInRole("Employee") && User.IsInRole("Manager"))
                {
                    return(RedirectToAction("Error", "Home", new { ErrorMessage = "This is not your account." }));
                }
            }

            // Ensure it's active
            if (BankAccount.Active == false)
            {
                return(RedirectToAction("Error", "Home", new { ErrorMessage = "This account is not active. Contact a manager for further advising." }));
            }

            // Get transactions associated with this bank account
            var transactions = from t in db.Transactions
                               where t.BankAccountID == BankAccount.BankAccountID
                               select t;
            List <Transaction> AllTransactions = transactions.ToList();


            /**
             * START filtering transactions
             */

            // Transaction ID filter
            if (TransactionID != null && TransactionID != "")
            {
                transactions = transactions.Where(t => t.TransactionID.Contains(TransactionID));
            }

            // Transaction type filter
            if (TransactionType != null && TransactionType != TransactionTypeEnum.All)
            {
                transactions = transactions.Where(t => t.TransactionType == TransactionType);
            }

            // Description filter
            if (Description != null && Description != "")
            {
                transactions = transactions.Where(t => t.Description.Contains(Description));
            }

            // Amount filter
            if (AmountLowerBound != null && AmountLowerBound != 0.00m && AmountUpperBound != null && AmountUpperBound != 0.00m)
            {
                transactions = transactions.Where(t => t.Amount > AmountLowerBound && t.Amount < AmountUpperBound);
            }
            else if (AmountLowerBound != null && AmountLowerBound != 0.00m)
            {
                transactions = transactions.Where(t => t.Amount > AmountLowerBound);
            }
            else if (AmountUpperBound != null && AmountUpperBound != 0.00m)
            {
                transactions = transactions.Where(t => t.Amount < AmountUpperBound);
            }

            // Date filter
            if (DateLowerBound != null && DateLowerBound != DateTime.MinValue && DateUpperBound != null && DateUpperBound != DateTime.MinValue)
            {
                transactions = transactions.Where(t => t.Date > DateLowerBound);
                transactions = transactions.Where(t => t.Date < DateUpperBound);
            }
            else if (AmountLowerBound != null && DateLowerBound != DateTime.MinValue)
            {
                transactions = transactions.Where(t => t.Date > DateLowerBound);
            }
            else if (AmountUpperBound != null && DateUpperBound != DateTime.MinValue)
            {
                transactions = transactions.Where(t => t.Date < DateUpperBound);
            }

            // Finally, sort the transactions
            transactions = transactions.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount);

            /**
             * END filtering transactions
             */

            // Create the ViewModel
            var model = new BankAccountDetailsViewModel {
                BankAccountID = BankAccount.BankAccountID, BankAccount = BankAccount, Transactions = transactions.ToList()
            };

            // Employees/Managers cannot create disputes
            if (User.IsInRole("Employee") || User.IsInRole("Manager"))
            {
                model.AllowDisputeCreation = false;
            }
            else
            {
                model.AllowDisputeCreation = true;
            }

            // Otherwise we're good, make any changes we need to
            if (BankAccount.AccountType == BankAccount.BankAccountTypeEnum.CheckingAccount)
            {
            }
            else if (BankAccount.AccountType == BankAccount.BankAccountTypeEnum.SavingsAccount)
            {
            }
            else if (BankAccount.AccountType == BankAccount.BankAccountTypeEnum.IRA)
            {
            }
            else if (BankAccount.AccountType == BankAccount.BankAccountTypeEnum.StockPortfolio)
            {
            }

            SelectedTransactions = transactions.ToList();

            // count # of records
            ViewBag.TransactionCount      = SelectedTransactions.Count();
            ViewBag.TotalTransactionCount = AllTransactions.Count();

            // First, ensure this bank account belongs to current customer
            return(View(model));
        }
        public BankAccountDetailsPage()
        {
            InitializeComponent();

            BindingContext = _viewModel = new BankAccountDetailsViewModel();
        }