public ActionResult Index(TransactionModel transactionModelTryingToAdd = null)
        {
            //Gets transactions / available account types for the given user, put them in a model to display it on the view
            TransactionModelList transactions = new TransactionModelList
            {
                TransactionModels     = transactionsAdapter.GetTransactionsByUID(Utilities.GetUsersUID(User.Identity.Name)),
                AvailableAccountTypes = accountTypeAdapter.GetAccountTypesByUID(Utilities.GetUsersUID(User.Identity.Name)).Select(x => new SelectListItem {
                    Value = x.ID.ToString(), Text = x.AccountType
                }),
                Categories = categoryAdapter.GetCategories().Select(x => new SelectListItem {
                    Value = x.ID.ToString(), Text = x.Category
                })
            };

            if (transactionModelTryingToAdd != null)
            {
                transactions.AddNewTransactionModel = transactionModelTryingToAdd;
            }

            transactions.AddNewTransactionModel.AvailableAccountTypeList = transactions.AvailableAccountTypes;
            transactions.AddNewTransactionModel.CategoryList             = transactions.Categories;


            ViewBag.IsNotDashboard = true;

            //Home page for transactions page
            return(View(transactions));
        }
        public JsonResult GetUserAccountTypes()
        {
            AccountTypeAdapter accountTypeAdapter = new AccountTypeAdapter();

            List <AccountTypeModel> accountTypes = accountTypeAdapter.GetAccountTypesByUID(Utilities.GetUsersUID(User.Identity.Name));

            return(Json(accountTypes.ToList(), JsonRequestBehavior.AllowGet));
        }
        public ActionResult AddAccountType(string typeName)
        {
            AccountTypeAdapter accountTypeAdapter = new AccountTypeAdapter();

            if (!accountTypeAdapter.GetAccountTypesByUID(User.Identity.Name).Exists(a => a.AccountType == typeName))
            {
                accountTypeAdapter.AddAccountType(new AccountTypeModel {
                    AccountType = typeName
                }, User.Identity.Name);
            }

            return(Json(true, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        public ActionResult Index()
        {
            //Get Budgets
            //Get Transactions
            ViewBag.AccountTypes = accountTypeAdapter.GetAccountTypesByUID(Utilities.GetUsersUID(User.Identity.Name)).Select(x => new SelectListItem {
                Value = x.ID.ToString(), Text = x.AccountType
            });
            var transactionList = transactionsAdapter.GetTransactionsByUID(Utilities.GetUsersUID(User.Identity.Name));

            ViewBag.Transactions = transactionList.GetRange(0, (transactionList.Count > 5) ? 5 : transactionList.Count);
            ViewBag.Categories   = categoryAdapter.GetCategories().Select(x => new SelectListItem {
                Value = x.ID.ToString(), Text = x.Category
            });
            ViewBag.Budgets     = budgetAdapter.GetBudgetsByUID(Utilities.GetUsersUID(User.Identity.Name));
            ViewBag.Frequencies = frequencyAdapter.GetAllFrequencies().Select(x => new SelectListItem {
                Value = x.ID.ToString(), Text = x.Frequency
            });
            //ViewBag.AccountTypes = accountTypeAdapter.GetAccountTypesByUID(Utilities.GetUsersUID(User.Identity.Name));

            return(View());
        }
        public ActionResult Index(BudgetModel BudgetTryingToAdd = null)
        {
            ViewBag.IsNotDashboard = true;

            BudgetAdapter      budgetAdapter      = new BudgetAdapter();
            FrequencyAdapter   frequencyAdapter   = new FrequencyAdapter();
            AccountTypeAdapter accountTypeAdapter = new AccountTypeAdapter();

            BudgetModelList pageData = new BudgetModelList
            {
                Budgets      = budgetAdapter.GetBudgetsByUID(Utilities.GetUsersUID(User.Identity.Name)),
                Categories   = budgetAdapter.GetUniqueCategoryByUID(Utilities.GetUsersUID(User.Identity.Name)),
                Frequencies  = frequencyAdapter.GetAllFrequencies(),
                AccountTypes = accountTypeAdapter.GetAccountTypesByUID(Utilities.GetUsersUID(User.Identity.Name))
            };

            if (BudgetTryingToAdd != null)
            {
                pageData.NewBudget = BudgetTryingToAdd;
            }

            return(View(pageData));
        }