public async Task<bool> AddAsync(Tenant tenant, ApplicationUser creator)
        {
            tenant.Creator = creator.UserName;

            _context.Tenants.Add(tenant);
            await _context.SaveChangesAsync();

            _myHealthDataInitializer.CreateTenantSampleData(_serviceProvider, tenant.TenantId);

            return true;
        }
        public async Task<bool> UpdateAsync(Tenant tenant)
        {
            var actualTenant = _context.Tenants
                .Where(t => t.TenantId == tenant.TenantId)
                .First();

            if (actualTenant == null)
                return false;

            actualTenant.Name = tenant.Name;
            actualTenant.Address = tenant.Address;
            actualTenant.City = tenant.City;
            actualTenant.AssociatedUsername = tenant.AssociatedUsername;

            _context.Tenants.Update(actualTenant);

            await _context.SaveChangesAsync();

            return true;
        }
        static async Task<int> CreateDefaultTenant(MyHealthContext context)
        {
            var tenant = new Tenant()
            {
                Name = "HealthClinic.biz",
                Address = "Madison Ave 10037",
                City = "New York",
                WaitTimeAvg = Randomize.Next(1, 10),
                AssociatedUsername = _configuration["DefaultUsername"],
                Creator = _configuration["DefaultAdminUsername"]
            };

            context.Tenants.Add(tenant);
            await context.SaveChangesAsync();

            return tenant.TenantId;
        }
        static int CreateTenants(MyHealthContext context)
        {
            var tenants = new List<Tenant>();
            var defaultTenant = new Tenant()
            {
                Name = "HealthClinic.biz",
                Address = "Madison Ave 10037",
                City = "New York",
                WaitTimeAvg = Randomize.Next(1, 10)
            };
            context.Tenants.Add(defaultTenant);

            var tenant = new Tenant()
            {
                Name = "Madison HealthCare",
                Address = "Madison Ave 10037",
                City = "New York",
                WaitTimeAvg = Randomize.Next(1, 10)
            };
            tenants.Add(tenant);

            tenant = new Tenant()
            {
                Name = "HCR Global",
                Address = "Spring Studios, 50. Varick St",
                City = "New York",
                WaitTimeAvg = Randomize.Next(1, 10)
            };
            tenants.Add(tenant);

            context.Tenants.AddRange(tenants);
            context.SaveChanges();

            return defaultTenant.TenantId;
        }
 private async Task<bool> AddAssociatedUserAsync(Tenant tenant, string password)
 {
     var associatedUser = new ApplicationUser { UserName = tenant.AssociatedUsername };
     associatedUser.TenantId = tenant.TenantId;
     return await _ApplicationUsersRepository.AddAsync(associatedUser, password);
 }