示例#1
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,Email,Password,ConfirmPassword,UserInformation")] Account account)
        {
            if (id != account.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    account.Salt     = SecurityHelper.PasswordHandle.GetInstance().GenerateSalt();
                    account.Password = SecurityHelper.PasswordHandle.GetInstance()
                                       .EncryptPassword(account.Password, account.Salt);
                    _context.Update(account);
                    _context.Update(account.UserInformation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountExists(account.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(account));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Logo,RedirectUrl,Description,CreatedAt,UpdatedAt,DeletedAt,Status")] RegisterApplication registerApplication)
        {
            if (id != registerApplication.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(registerApplication);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RegisterApplicationExists(registerApplication.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(registerApplication));
        }