Exemplo n.º 1
0
        public IActionResult Add(AddBankAccountViewModel accountViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            User user = userRepository.GetByUsername(User.Identity.Name);

            BankAccount bankAccount = new BankAccount()
            {
                AccountId = accountViewModel.AccountId,
                Titular   = accountViewModel.Titular,
                UserId    = user.Id
            };

            repository.AddEntity(bankAccount);

            User newUser = new User()
            {
                AccountID   = bankAccount.Id,
                Active      = true,
                Name        = user.Name,
                City        = accountViewModel.City,
                Email       = user.Email,
                Id          = user.Id,
                Info        = user.Info,
                LastName    = user.LastName,
                PhoneNumber = accountViewModel.Telephone,
                UserName    = user.UserName
            };

            userRepository.Update(newUser);

            return(RedirectToAction("Index", "Home"));
        }