public async Task <IActionResult> CreateUser(CreateApplicationUserDto dto)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser newApplicationUser = new()
                {
                    Email       = dto.Email,
                    FirstName   = dto.FirstName,
                    LastName    = dto.LastName,
                    UserName    = dto.UserName,
                    PhoneNumber = dto.PhoneNumber,
                };
                IdentityResult createUserResult = await _userManager.CreateAsync(newApplicationUser, dto.Password);

                if (createUserResult.Succeeded)
                {
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    foreach (var error in createUserResult.Errors)
                    {
                        ModelState.AddModelError(string.Empty, error.Description);
                    }
                    return(View(dto));
                }
            }
            return(View(dto));
        }
        public async Task <IActionResult> CreateUser(CreateApplicationUserDto dto)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser newApplicationUser = new()
                {
                    Email       = dto.Email,
                    FirstName   = dto.FirstName,
                    LastName    = dto.LastName,
                    UserName    = dto.UserName,
                    PhoneNumber = dto.PhoneNumber,
                };

                if (dto.Roles is not null)
                {
                    var roles = await _db.Roles.Where(r => dto.Roles.Contains(r.Name))
                                .ToListAsync();

                    newApplicationUser.Roles = roles; // Using Skip Navigation
                }

                IdentityResult createUserResult = await _userManager.CreateAsync(newApplicationUser, dto.Password);

                if (createUserResult.Succeeded)
                {
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    foreach (var error in createUserResult.Errors)
                    {
                        ModelState.AddModelError(string.Empty, error.Description);
                    }
                    await GetRolesSelectList();

                    return(View(dto));
                }
            }

            await GetRolesSelectList();

            return(View(dto));
        }