public ActionResult Passbook() { PassbookViewModel vm = new PassbookViewModel(); using (new UnitOfWork.UnitOfWorkScope <BankingDbContext>(UnitOfWork.UnitOfWorkScopePurpose.Reading)) { AuthenticationService authenticate = new AuthenticationService(); var userEmail = (string)HttpContext.Session["User"]; var user = authenticate.GetUser(userEmail); vm.Username = user.Name; return(View(vm)); } }
public ActionResult Passbook(PassbookViewModel vm) { using (new UnitOfWork.UnitOfWorkScope <BankingDbContext>(UnitOfWork.UnitOfWorkScopePurpose.Reading)) { 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.Flag = false; if (account != null) { vm.Flag = true; vm.Account = account; } if (vm.Flag == false) { vm.Message = "Account does not exist"; } return(View(vm)); } }