示例#1
0
        public static bool AddNewEntry(DbDirectoryEntry newEntryToAdd, out AddDirectoryEntryFailReason result)
        {
            DbDirectoryEntry possiblyExistingEntry = GetEntryByName(newEntryToAdd.Name);

            if (possiblyExistingEntry != null)
            {
                result = AddDirectoryEntryFailReason.allreadyExistsDuplicateName;
                return(false);
            }

            possiblyExistingEntry = GetUserByTelephone(newEntryToAdd.TelephoneNumber);
            if (possiblyExistingEntry != null)
            {
                result = AddDirectoryEntryFailReason.allreadyExistsDuplicatePhoneNumber;
                return(false);
            }

            var newid = Directory.Max(x => x.Pkid);

            newEntryToAdd.Pkid = newid;
            Directory.Add(newEntryToAdd);

            result = AddDirectoryEntryFailReason.noErrorEntryAdded;
            return(true);
        }
示例#2
0
        public static bool AddNewEntry(DbDirectoryEntry newEntryToAdd, out AddDirectoryEntryFailReason result)
        {
            DbDirectoryEntry possiblyExistingEntry = GetEntryByName(newEntryToAdd.Name);
              if (possiblyExistingEntry != null)
              {
            result = AddDirectoryEntryFailReason.allreadyExistsDuplicateName;
            return false;
              }

              possiblyExistingEntry = GetUserByTelephone(newEntryToAdd.TelephoneNumber);
              if (possiblyExistingEntry != null)
              {
            result = AddDirectoryEntryFailReason.allreadyExistsDuplicatePhoneNumber;
            return false;
              }

              var newid = Directory.Max(x => x.Pkid);
              newEntryToAdd.Pkid = newid;
              Directory.Add(newEntryToAdd);

              result = AddDirectoryEntryFailReason.noErrorEntryAdded;
              return true;
        }