public IActionResult CreateNewSavings()
        {
            NewSavingsAccountViewModel vm = new NewSavingsAccountViewModel();

            vm.CustomerList = Utility.Utility.GetBankData(_env.WebRootPath).PrivateCustomers;
            return(View(vm));
        }
 public IActionResult CreateNewSavings(NewSavingsAccountViewModel vm)
 {
     if (!vm.CustomerList.Any(pc => pc.IsSelected))
     {
         vm.DisplayMessage = "Must select at least one account owner";
         return(View(vm));
     }
     else if (vm.InitialBalance < 0)
     {
         vm.DisplayMessage = "Please input a positive sum for initial balance";
         return(View(vm));
     }
     else
     {
         //get bank data, then save account to file and send back to start page
         var bank           = Utility.Utility.GetBankData(_env.WebRootPath);
         var selectedOwners = vm.CustomerList.Where(pc => pc.IsSelected); // small issue, but I prefer to use my file as the proper datastore!
         var owners         = new List <PrivateCustomer>();
         foreach (var owner in selectedOwners)
         {
             owners.Add(bank.PrivateCustomers.Single(pc => pc.CustomerID == owner.CustomerID));
         }
         var account = new SavingsAccount(owners, vm.InitialBalance);
         bank.SavingsAccounts.Add(account);
         //now save to file
         Utility.Utility.SaveBankData(_env.WebRootPath, bank);
         return(RedirectToAction("Index", "Home", new { message = Message.CreatePrivateAccountSuccess }));
     }
 }