public async Task <ActionResult> Edit(
            string id,
            [Bind(Prefix = "Properties")] FaToolPersonalProperties properties)
        {
            var user = await UserManager.FindByIdAsync(id);

            if (user == null)
            {
                return(HttpNotFound("User not found."));
            }

            if (User.IsUserOrInRole(user.UserName, FaToolRoles.ADMIN) == false)
            {
                return(HttpStatusCodeResults.HttpUnauthorized());
            }

            if (ModelState.IsValid)
            {
                user.SetProperties(properties);

                IdentityResult result = await UserManager.UpdateAsync(user);

                if (result.Succeeded)
                {
                    return(Redirect(ShowUserAction(user).Url));
                }
                else
                {
                    AddErrors(result);

                    var model = new EditUserViewModel(
                        user,
                        properties,
                        GetCountryOptions(properties.Country));

                    return(View(model));
                }
            }
            else
            {
                var model = new EditUserViewModel(
                    user,
                    properties,
                    GetCountryOptions(properties.Country));

                return(View(model));
            }
        }
        public async Task <ActionResult> Edit(string id)
        {
            var user = await UserManager.FindByIdAsync(id);

            if (user == null)
            {
                return(HttpNotFound("User not found."));
            }

            if (User.IsUserOrInRole(user.UserName, FaToolRoles.ADMIN) == false)
            {
                return(HttpStatusCodeResults.HttpUnauthorized());
            }

            var model = new EditUserViewModel(
                user,
                GetCountryOptions(user.Country));

            return(View("Edit", model));
        }
        public async Task <ActionResult> Get(string id)
        {
            var user = await UserManager.FindByIdAsync(id);

            if (user == null)
            {
                return(HttpNotFound("User not found."));
            }

            if (User.IsUserOrInRole(user.UserName, FaToolRoles.ADMIN) == false)
            {
                return(HttpStatusCodeResults.HttpUnauthorized());
            }

            var model = new UserViewModel(user);

            model.Properties.Actions.Add(EditUserAction(user));
            model.Properties.Actions.Add(ChangePasswordAction(user));
            model.Properties.Actions.Add(GrantRolesAction(user));
            model.Properties.Actions.Add(LockUserAction(user));
            model.Properties.Actions.Add(ShowUserListAction());

            return(View("User", model));
        }