public IActionResult Create(ApplicationUser applicationUser)
 {
     if (ModelState.IsValid)
     {
         _context.ApplicationUser.Add(applicationUser);
         _context.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(applicationUser);
 }
        public async Task<IActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl = null)
        {
            if (User.IsSignedIn())
            {
                return RedirectToAction(nameof(HomeController.Index), "Home");
            }

            if (ModelState.IsValid)
            {
                // Get the information about the user from the external login provider
                var info = await _signInManager.GetExternalLoginInfoAsync();
                if (info == null)
                {
                    return View("ExternalLoginFailure");
                }
                var user = new ApplicationUser { UserName = model.UserName};
                string pathToCreate = Path.Combine(_hostingEnvironment.WebRootPath, "Photos", model.UserName);

                var result = await _userManager.CreateAsync(user);
                if (result.Succeeded)
                {
                    result = await _userManager.AddLoginAsync(user, info);
                    if (result.Succeeded)
                    {
                        await _userManager.AddToRoleAsync(user, "Member");
                        await _signInManager.SignInAsync(user, isPersistent: false);
                        if (!Directory.Exists(pathToCreate))
                        {
                            Directory.CreateDirectory(pathToCreate);
                        }
                        else
                        {
                            return View("FolderCreationFailure");
                        }
                        _logger.LogInformation(6, "User created an account using {Name} provider.", info.LoginProvider);

                        return RedirectToLocal(returnUrl);
                    }
                }
                AddErrors(result);                
            }
            ViewData["ReturnUrl"] = returnUrl;
            return View(model);
        }