/// <summary>
        /// Seed an initial Admin user
        /// </summary>
        private void SeedInitialUserAndRole()
        {
            string emailAddress = "*****@*****.**";
            if (!_context.Users.Any(u => u.UserName == emailAddress))
            {
                var roleStore = new RoleStore<IdentityRole>(_context);
                var roleManager = new RoleManager<IdentityRole>(roleStore);

                var store = new UserStore<ApplicationUser>(_context);
                var manager = new UserManager<ApplicationUser>(store);
                Tenant tenant = _context.Tenants.First(t => t.Name == "Polar");
                if (tenant != null)
                {
                    IList<Tenant> tenants = new List<Tenant>();
                    tenants.Add(tenant);
                    var user = new ApplicationUser { UserName = emailAddress, Email = emailAddress, UserTenants = tenants };

                    roleManager.Create(new IdentityRole { Name = EnumHelper.Roles.Admin.ToString() });
                    manager.Create(user, "password");
                    manager.AddToRole(user.Id, EnumHelper.Roles.Admin.ToString());

                    SeedUserSettings seedUserSettings = new SeedUserSettings(user.Id);

                }
            }
        }
 public void CheckSeededData()
 {
     SeedUserSettings seedUserSettings = new SeedUserSettings(_userId);
 }
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            string gCaptcha = HttpContext.Request.Params["g-recaptcha-response"];
            string userIpAddress = Request.ServerVariables["REMOTE_ADDR"];
            if (!string.IsNullOrWhiteSpace(gCaptcha) && UtilityHelper.IsGoogleReCaptchaValid(gCaptcha, userIpAddress))
            {
                if (ModelState.IsValid)
                {
                    Tenant tenant = new Tenant
                    {
                        Name = model.OrganisationName
                    };
                    IList<Tenant> tenants = new List<Tenant>();
                    tenants.Add(tenant);

                    var user = new ApplicationUser() { 
                        UserName = model.Email, 
                        FirstName = model.FirstName,
                        LastName = model.LastName,
                        OrganisationalRole = model.OrganisationalRole,
                        PhoneNumber = model.TelephoneNumber,
                        Email = model.Email, 
                        UserTenants = tenants };
                    IdentityResult result = await UserManager.CreateAsync(user, model.Password);
                    result = await UserManager.AddToRoleAsync(user.Id, EnumHelper.Roles.Author.ToString());

                    SeedUserSettings seedUserSettings = new SeedUserSettings(user.Id);

                    if (result.Succeeded)
                    {
                        await SignInAsync(user, isPersistent: false);

                        // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                        // Send an email with this link
                        // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                        // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                        // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                        return RedirectToAction("Index", "Home");
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }
            Alert(EnumHelper.Alerts.Error, HIResources.Strings.Change_Error);
            // If we got this far, something failed, redisplay form
            return View(model);
        }