public IActionResult Edit(UserViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                // Verify not exist on id
                var key = new UserKey()
                {
                    Id = viewModel.Id
                };
                var user = _usersService.GetUser(key);
                if (user != null)
                {
                    user.Id        = viewModel.Id;
                    user.Name      = viewModel.Name;
                    user.Email     = viewModel.Email;
                    user.Suspended = viewModel.Suspended;

                    //Verify role exist
                    var roleKey = new RoleKey();
                    roleKey.Id = viewModel.RoleId;
                    var role = _rolesService.GetRole(roleKey);
                    if (role != null)
                    {
                        user.Role = role;
                        user      = _usersService.UpdateUser(user);
                        return(RedirectToAction("Index"));
                    }
                }
            }

            // Populate SelectListItem of roles
            ViewBag.Roles = ControllerUtils.CreateSelectRoleItemList(_rolesService.FindRoles(), viewModel.Id);
            return(View(viewModel));
        }
        public IActionResult Edit(string id)
        {
            if (!string.IsNullOrWhiteSpace(id))
            {
                var key = new UserKey()
                {
                    Id = id
                };
                var user = _usersService.GetUser(key);
                if (user != null)
                {
                    var viewModel = new UserViewModel()
                    {
                        Id               = user.Id,
                        Name             = user.Name,
                        Email            = user.Email,
                        RegistrationDate = user.RegistrationDate,
                        LastLoginDate    = user.LastLoginDate,
                        Suspended        = user.Suspended
                    };
                    if (user.Role != null)
                    {
                        viewModel.RoleId = user.Role.Id;
                    }

                    // Populate SelectListItem of roles
                    ViewBag.Roles = ControllerUtils.CreateSelectRoleItemList(_rolesService.FindRoles(), user.Id);
                    return(View(viewModel));
                }
            }

            return(RedirectToAction("Index"));
        }