Esempio n. 1
0
        public PhoneBookEntry CreatePhoneBookEntry(string firstName, string lastName, PhoneType typeOfPhone, string number)
        {
            int index = LocateUser(ListOfAddedEntries, firstName, lastName);

            if (index >= 0)
            {
                throw new System.ArgumentException("This user already exists!");
            }
            if (firstName.Length <= 1)
            {
                throw new System.ArgumentException("The name is too short!");
            }

            PhoneBookEntry newUser = new PhoneBookEntry(firstName, lastName, typeOfPhone, number);
            this.ListOfAddedEntries.Add(newUser);
            return newUser;
        }
Esempio n. 2
0
        public PhoneBookEntry CreatePhoneBookEntry(string firstName, string lastName, PhoneType typeOfPhone, string number)
        {
            int index = LocateUser(ListOfAddedEntries, firstName, lastName);

            if (index >= 0)
            {
                throw new System.ArgumentException("This user already exists!");
            }
            if (firstName.Length <= 1)
            {
                throw new System.ArgumentException("The name is too short!");
            }

            PhoneBookEntry newUser = new PhoneBookEntry(firstName, lastName, typeOfPhone, number);

            this.ListOfAddedEntries.Add(newUser);
            return(newUser);
        }
Esempio n. 3
0
        // Interface methods implementation
        public PhoneBookEntry CreatePhoneBookEntry(string firstName, string lastName)
        {
            if (firstName == null || lastName == null)
            {
                throw new System.ArgumentNullException("No name entered!");
            }

            int index = LocateUser(ListOfAddedEntries, firstName, lastName);

            if (index >= 0)
            {
                throw new System.ArgumentException("This user already exists!");
            }

            PhoneBookEntry newUser = new PhoneBookEntry(firstName, lastName);
            this.ListOfAddedEntries.Add(newUser);
            return newUser;
        }
Esempio n. 4
0
        // Interface methods implementation

        public PhoneBookEntry CreatePhoneBookEntry(string firstName, string lastName)
        {
            if (firstName == null || lastName == null)
            {
                throw new System.ArgumentNullException("No name entered!");
            }

            int index = LocateUser(ListOfAddedEntries, firstName, lastName);

            if (index >= 0)
            {
                throw new System.ArgumentException("This user already exists!");
            }

            PhoneBookEntry newUser = new PhoneBookEntry(firstName, lastName);

            this.ListOfAddedEntries.Add(newUser);
            return(newUser);
        }