public ActionResult Verify(string name)
 {
     using (var unitOfWork = new UnitOfWork.UnitOfWorkScope <BankingDbContext>(UnitOfWork.UnitOfWorkScopePurpose.Writing))
     {
         AuthenticationService authenticate = new AuthenticationService();
         var user = authenticate.GetUser(name);
         user.Verified = "True";
         unitOfWork.SaveChanges();
         return(RedirectToAction("Login"));
     }
 }
        public ActionResult Transaction(TransactionViewModel vm)
        {
            using (var unitOfWork = new UnitOfWork.UnitOfWorkScope <BankingDbContext>(UnitOfWork.UnitOfWorkScopePurpose.Writing))
            {
                if (ModelState.IsValid)
                {
                    AuthenticationService authenticate = new AuthenticationService();
                    var     userEmail = (string)HttpContext.Session["User"];
                    var     user      = authenticate.GetUser(userEmail);
                    Account account   = null;
                    try
                    {
                        account =
                            _efrAccount.GetDbSet()
                            .Where(x => x.User.Id == user.Id)
                            .Where(x => x.AccountType == vm.AccountType)
                            .Include(m => m.TransactionList)
                            .First();
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                    vm.UserName = user.Name;
                    vm.Flag     = false;

                    if (account != null)
                    {
                        vm.Flag    = true;
                        vm.Account = account;
                        Transaction transaction = new Transaction(vm.Amount, vm.TransactionType, DateTime.Now)
                        {
                            Account = account
                        };
                        vm.Account.TransactionList.Add(transaction);
                        vm.Message = "Transaction Successfull";
                        //_efrTransaction.Add(transaction);
                    }


                    if (vm.Flag == false)
                    {
                        vm.Message = "Account does not exist";
                    }
                    unitOfWork.SaveChanges();
                }

                return(View(vm));
            }
        }
        public ActionResult AddRecipient()
        {
            AddRecipientViewModel vm = new AddRecipientViewModel();

            using (
                var unitOfWork =
                    new UnitOfWork.UnitOfWorkScope <BankingDbContext>(UnitOfWork.UnitOfWorkScopePurpose.Writing))
            {
                AuthenticationService authenticate = new AuthenticationService();
                var userEmail = (string)HttpContext.Session["User"];
                var user      = authenticate.GetUser(userEmail);
                vm.UserName = user.Name;
            }
            return(View(vm));
        }
        public ActionResult Recipient(RecipientViewModel vm)
        {
            using (var unitOfWork = new UnitOfWork.UnitOfWorkScope <BankingDbContext>(UnitOfWork.UnitOfWorkScopePurpose.Writing))
            {
                AuthenticationService authenticate = new AuthenticationService();
                var userEmail = (string)HttpContext.Session["User"];
                var user      = authenticate.GetUser(userEmail);
                vm.UserName = user.Name;

                if (ModelState.IsValid && vm.Name != null)
                {
                    vm.SelectedList = PopulateList();

                    try
                    {
                        var account =
                            _efrAccount.GetDbSet()
                            .Where(x => x.User.Id == user.Id)
                            .Where(x => x.AccountType == vm.AccountType)
                            .Include(m => m.TransactionList)
                            .First();
                        var recipient =
                            _efrRecipient.GetDbSet()
                            .Where(x => x.User.Id == user.Id)
                            .Where(x => x.Name == vm.Name)
                            .First();
                        recipient.Balance += vm.Amount;
                        account.TransactionList.Add(new Transaction(vm.Amount, TransactionType.WITHDRAW.ToString(),
                                                                    DateTime.Now));
                        vm.Message = "Transaction successful with Recipient";
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                    unitOfWork.SaveChanges();
                }
            }
            return(View(vm));
        }