Esempio n. 1
0
    public override IEnumerable <Expression <Func <User, bool> > > GetPredicates()
    {
        if (Email.HasValue())
        {
            yield return(entity => entity.Email == Email);
        }

        if (SignupToken.HasValue())
        {
            yield return(entity => entity.SignupToken == SignupToken);
        }

        if (ResetPasswordToken.HasValue())
        {
            yield return(entity => entity.ResetPasswordToken == ResetPasswordToken);
        }

        if (IdToExclude.HasValue)
        {
            yield return(entity => entity.Id != IdToExclude);
        }

        if (SearchValue.HasValue())
        {
            yield return(entity => entity.FirstName.Contains(SearchValue) ||
                         entity.LastName.Contains(SearchValue) ||
                         entity.Email.Contains(SearchValue));
        }
    }
        public static bool TryAddTenant(string tenantId, string signupToken)
        {
            if (!ContainsTenant(tenantId))
            {
                using (TenantDbContext context = new TenantDbContext())
                {
                    SignupToken existingToken = context.SignupTokens.Where(token => token.Id == signupToken).FirstOrDefault();
                    if (existingToken != null)
                    {
                        context.SignupTokens.Remove(existingToken);
                        context.Tenants.Add(new Tenant {
                            Id = tenantId
                        });
                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }