Exemple #1
0
        public async Task <IActionResult> Edit(int id, Account account)
        {
            if (id != account.CustomerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    account.UpdatedAt = DateTime.Today;
                    if (account.Password != null)
                    {
                        account.EncryptPassword(account.Password);
                    }
                    _context.Update(account);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountExists(account.CustomerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(account));
        }