Example #1
0
        public async Task <IActionResult> Index()
        {
            if (User.Identity.IsAuthenticated)
            {
                var st = WebRequests.TokenGrabber(User.Identity.Name);

                var json = await WebRequests.JsonGet("http://localhost:61506/api/Trans/", st);

                var         transList = JsonConvert.DeserializeObject <List <Transaction> >(json);
                BankAccount sav       = new SavingsAccount(transList);
                BankAccount chk       = new CheckingAccount(transList);

                ViewBag.SavingsBalance   = sav.GetBalance().ToString("C");
                ViewBag.SavingsInterest  = sav.GetInterest().ToString("C");
                ViewBag.CheckingBalance  = chk.GetBalance().ToString("C");
                ViewBag.CheckingInterest = chk.GetInterest().ToString("C");
                ViewBag.SavingsLatest    = sav.GetLatest();
                ViewBag.CheckingLatest   = chk.GetLatest();
                return(View());
            }
            return(RedirectToAction("Login", "Account"));
        }