public ActionResult Account(AccountViewModel 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;
                var  account = _efrAccount.GetDbSet().Where(x => x.User.Id == user.Id).Include(m => m.TransactionList).ToList();
                bool flag    = false;

                foreach (var acc in account)
                {
                    if (acc.AccountType.Equals(AccountType.SAVING.ToString()))
                    {
                        flag       = true;
                        vm.Message = "Saving Account Exist for User" + user.Name + " Amount " + acc.Balance;
                    }
                }

                if (flag == false)
                {
                    Account savingAccount = new Account(AccountType.SAVING.ToString(), 5000)
                    {
                        User = user
                    };
                    _efrAccount.Add(savingAccount);
                    vm.Message = "Account Successfully Created";
                }
                unitOfWork.SaveChanges();
            }
            return(View(vm));
        }
 public ActionResult Register(RegisterViewModel vm)
 {
     if (ModelState.IsValid)
     {
         vm.Role          = UserType.USER.ToString();
         vm.AccountStatus = AccountStatus.ACTIVE.ToString();
         vm.Verified      = false.ToString();
         using (
             var unitOfWork =
                 new UnitOfWork.UnitOfWorkScope <BankingDbContext>(UnitOfWork.UnitOfWorkScopePurpose.Writing))
         {
             User user = new User(vm.Gmail, vm.Name, vm.Password, vm.Age, vm.Gender, vm.Role, vm.AccountStatus,
                                  vm.Verified);
             Account accountCurrent = new Account(AccountType.CURRENT.ToString(), 10000)
             {
                 User = user
             };
             _efrAccount.Add(accountCurrent);
             _efrUser.Add(user);
             unitOfWork.SaveChanges();
             string       link         = "http://localhost:53934/Login/Verify?name=" + user.Gmail;
             EmailService emailService = new EmailService();
             emailService.SendRegisterMail("Activate Account", user.Gmail, user.Name, link);
             return(RedirectToAction("Login"));
         }
     }
     return(View(vm));
 }