public ActionResult Details(int id) { var reservationsContext = _savingLogic.GetSavingReservations(id); ViewBag.Reservations = reservationsContext.Select(reserve => new ReservationViewModel(reserve)); var savingContext = _savingLogic.GetSavingById(id); var model = new SavingsViewModel(savingContext.UserId, id, savingContext.SavingName, savingContext.SavingCurrentAmount, savingContext.SavingsGoalAmount, savingContext.State, savingContext.IconId, savingContext.GoalDate); ViewBag.FileProvider = _fileProvider.GetDirectoryContents("wwwroot/Icons/Savings").ToList().Select(icon => icon.Name).ToList(); ViewBag.Accounts = _accountLogic.GetUserAccounts(HttpContext.Session.GetString("UserSession")); ViewBag.Savings = _savingLogic.GetOngoingUserSavings((int)HttpContext.Session.GetInt32("UserId")); return(View("~/Views/Savings/SavingDetails.cshtml", model)); }
public ActionResult Index(int id) { var userHasAccess = false; var usersContext = _accountLogic.GetAccountUsers(id).ToList(); foreach (var user in usersContext) { if (user.Username == HttpContext.Session.GetString("UserSession")) { userHasAccess = true; } } if (!userHasAccess) { return(RedirectToAction("Index", "Account")); } var accountDetails = _accountLogic.GetAccountById(id); var categoriesContext = _transactionLogic.GetCategories(); var categories = categoriesContext.Select(category => new SelectListItem(category.Name, category.Name)).ToList(); ViewBag.Categories = categories; ViewBag.BillId = id; ViewBag.BillName = accountDetails.AccountName; ViewBag.Balance = accountDetails.AccountBalance; ViewBag.FileProvider = _fileProvider.GetDirectoryContents("wwwroot/Icons/Category").ToList().Select(icon => icon.Name).ToList(); ViewBag.Savings = _savingLogic.GetOngoingUserSavings((int)HttpContext.Session.GetInt32("UserId")); ViewBag.Accounts = _accountLogic.GetUserAccounts(HttpContext.Session.GetString("UserSession")); ViewBag.Users = _userLogic.GetAllUsers(); var transactionsContext = _transactionLogic.GetBillTransactions(id); var transactions = transactionsContext.Select(trans => new TransactionsViewModel(trans.TransactionId, trans.AccountId, trans.TransactionName, trans.TransactionAmount, trans.Category, trans.IconId, trans.TimeOfTransaction, _fileProvider.GetDirectoryContents("wwwroot/Icons/Bill").ToList().Select(icon => icon.Name).ToList())).ToList(); var scheduledTransactionsContext = _transactionLogic.GetAccountScheduledTransactions(id); var scheduledTransactions = scheduledTransactionsContext.Select(trans => new TransactionsViewModel(trans.TransactionId, trans.AccountId, trans.TransactionName, trans.TransactionAmount, trans.Category, trans.IconId, trans.TimeOfTransaction, _fileProvider.GetDirectoryContents("wwwroot/Icons/Bill").ToList().Select(icon => icon.Name).ToList())).ToList(); var model = new TransactionOverviewViewModel(transactions, scheduledTransactions); return(View("~/Views/Transaction/Transactions.cshtml", model)); }
public ActionResult Index() { try { ViewBag.FileProvider = _fileProvider.GetDirectoryContents("wwwroot/Icons/Bill").ToList().Select(icon => icon.Name).ToList(); var accountContext = _accountLogic.GetAccountsByUsername(HttpContext.Session.GetString("UserSession")); var accounts = (accountContext.Select(account => new AccountViewModel(account.AccountId, account.AccountName, account.AccountBalance, account.Transactions, account.IconId, account.UserIds, _fileProvider.GetDirectoryContents("wwwroot/Icons/Bill").ToList().Select(icon => icon.Name).ToList(), _accountLogic.GetAccountReservations(account.AccountId)))); var savingContext = _savingLogic.GetOngoingUserSavings((int)HttpContext.Session.GetInt32("UserId")); var savings = savingContext.Select(saving => new SavingsViewModel(saving.UserId, saving.SavingId, saving.SavingName, saving.SavingCurrentAmount, saving.SavingsGoalAmount, saving.State, saving.IconId, saving.GoalDate)); var model = new LandingPageViewModel(accounts, savings); return(View("~/Views/Shared/Overview.cshtml", model)); } catch (Exception e) { Console.WriteLine(e); return(RedirectToAction("Index", "Home")); } }