Пример #1
0
        public async Task <IActionResult> Edit(UserEditModel userEditModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    User entity = await _servicioUsuario.GetById(userEditModel.Id);

                    if (entity == null)
                    {
                        return(View(userEditModel));
                    }

                    userEditModel.ToEntity(entity);
                    _context.Update(entity);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(userEditModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(userEditModel));
        }