Esempio n. 1
0
        public override bool Equals(object obj)
        {
            UserContact compareTo = obj as UserContact;

            if (compareTo == null)
            {
                throw new Exception("Can't compare objects of different types");
            }

            return(compareTo.Type == this.Type);
        }
Esempio n. 2
0
        public virtual void Add(UserContact userContact)
        {
            if (userContact == null)
            {
                throw new ValidationException("User contact can't be empty");
            }

            if (this.contacts.Contains(userContact))
            {
                throw new ValidationException("User contact already exists");
            }

            this.contacts.Add(userContact);

            this.DateModified = TimeProvider.Current.UtcNow;
        }
Esempio n. 3
0
        public virtual void Remove(UserContact userContact)
        {
            if (userContact == null)
            {
                throw new ValidationException("User contact can't Be Empty");
            }

            if (!this.contacts.Contains(userContact))
            {
                throw new ValidationException("User contact doesn't Exist");
            }

            this.contacts.Remove(userContact);

            this.DateModified = TimeProvider.Current.UtcNow;
        }
Esempio n. 4
0
        public static UserContact Create(User user, Contact type, string value)
        {
            if (user == null)
            {
                throw new ValidationException("User can't be empty");
            }

            if (String.IsNullOrEmpty(value))
            {
                throw new ValidationException("Value can't be empty");
            }

            UserContact userContact = new UserContact();

            userContact.Id     = Guid.NewGuid();
            userContact.Type   = type;
            userContact.UserId = user.Id;
            userContact.Value  = value;
            return(userContact);
        }