Exemple #1
0
        public Profile WithUniqueName(Profile profile)
        {
            if (profile == null)
            {
                return(null);
            }

            using (var cached = _cachedProfiles.ProfileData())
            {
                var local = cached.Local.Where(x => x.Status != ProfileStatus.Deleted).ToList();
                var sync  = cached.Local.Where(x => x.Status != ProfileStatus.Deleted).ToList();
                var p     = profile.WithUniqueNameCandidate(_appConfig.MaxProfileNameLength);
                while (ContainsOtherWithSameName(local, p) ||
                       ContainsOtherWithSameName(sync, p) ||
                       ContainsOtherWithSameName(cached.External, p))
                {
                    p = p.WithNextUniqueNameCandidate(_appConfig.MaxProfileNameLength);
                }

                return(p);
            }
        }
Exemple #2
0
 public static Profile WithNextUniqueNameCandidate(this Profile profile, int maxLength)
 {
     profile.UniqueNameIndex++;
     return(profile.WithUniqueNameCandidate(maxLength));
 }