public async Task <IActionResult> Update(UserManagerUpdateCommandModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (await _service.UpdateUser(model))
            {
                return(RedirectToAction("Index", "Home"));
            }

            ModelState.TryAddModelError("", "Somthing went wrong unable to update");
            return(View(model));
        }
        public async Task <UserManagerUpdateCommandModel> FindUserByName(string username)
        {
            var user = await _userManager.FindByNameAsync(username);

            if (user == null)
            {
                return(null);
            }

            var manageUser = new UserManagerUpdateCommandModel
            {
                FirstName    = user.FirstName,
                LastName     = user.LastName,
                EmailAddress = user.Email,
                PhoneNumber  = user.PhoneNumber,
                UserName     = user.UserName,
            };

            return(manageUser);
        }
        public async Task <bool> UpdateUser(UserManagerUpdateCommandModel model)
        {
            var user = await _userManager.FindByNameAsync(model.UserName);

            if (user == null)
            {
                return(false);
            }

            user.FirstName   = model.FirstName;
            user.LastName    = model.LastName;
            user.Email       = model.EmailAddress;
            user.PhoneNumber = model.PhoneNumber;
            user.UserName    = model.UserName;

            var isUpdated = await _context.SaveChangesAsync();

            if (isUpdated > -1)
            {
                return(true);
            }

            return(false);
        }