public async Task <IActionResult> Details(UserDetailsViewModel model)
        {
            model._context         = _context;
            model._securityOptions = _securityOptions;
            model._emailService    = _emailService;
            model._user            = User;

            try
            {
                if (ModelState.IsValid)
                {
                    if (model.UserRoles.Any(x => x.Selected == true) == false)
                    {
                        ViewBag.Error = "At least one user role must be specified";
                    }
                    else if (string.IsNullOrEmpty(model.EmailAddress))
                    {
                        ViewBag.Error = "Email address must be specified";
                    }
                    else
                    {
                        Guid userID = Guid.Empty;

                        userID = await model.Save();

                        if (userID != Guid.Empty)
                        {
                            if (!string.IsNullOrEmpty(model._tmpPassword))
                            {
                                TempData["tmpPassword"] = model._tmpPassword;
                            }
                            else
                            {
                                TempData["tmpPassword"] = null;
                            }
                            return(RedirectToAction("Details", new { ID = userID, Success = true }));
                        }
                        else
                        {
                            ViewBag.Error = model.errorMessage;
                        }
                    }
                }
                else
                {
                    ViewBag.Error = "Please make sure the required fields are added including the login type.";
                }
            }
            catch (Exception ex)
            {
                HelperFunctions.Log(_context, PublicEnums.LogLevel.LEVEL_EXCEPTION, "Controllers.UsersController.Details", ex.Message, User, ex);
                ViewBag.Error = "An error occurred. Please try again later.";
            }
            finally
            {
                await model.PopulateLists();
            }
            return(View(model));
        }