public void Add(IContactInfo alternateContact)
        {
            Contract.Requires <ArgumentNullException>(alternateContact != null);
            Contract.Requires <ArgumentException>(!this.Contains(alternateContact));

            this.OtherContacts.Add(alternateContact);
        }
Exemple #2
0
        private void SaveNewContact(IContactInfo NewContact)
        {
            //var rnd = new Random();
            //var allContacts = _book.GetContacts().ToArray();
            //var contact = allContacts[rnd.Next(allContacts.Length)];

            var file = new VCardFile(
                new VCardEntry(
                    string.Empty,
                    new ContentLine(Names.VERSION, "3.0"),
                    new ContentLine(Names.N, NewContact.LastName + ";" + NewContact.FirstName),
                    new ContentLine(Names.FN, NewContact.LastName + " " + NewContact.FirstName),
                    new ContentLine(Names.NICKNAME, NewContact.Nickname),
                    new ContentLine(Names.BDAY, NewContact.Birthday),
                    new ContentLine(Names.TEL, NewContact.Phone),
                    new ContentLine(Names.EMAIL, NewContact.Email),
                    new ContentLine(Names.MAILER, NewContact.Mailer),
                    new ContentLine(Names.NOTE, NewContact.Note)
                    )
                );

            //var e = file.Entries.First();
            //var rawName = e.Contents.FirstOrDefault(c => c.Name == Names.N);
            //var name = rawName.Value.Split(';');

            using (var stream = File.OpenWrite(@"D:/contacts/" + _book.Count() + "_contact.vcf"))
                using (var writer = new StreamWriter(stream))
                {
                    file.WriteTo(writer);
                }
        }
Exemple #3
0
        public string InsertOrUpdateContact(IContactInfo contact)
        {
            string result = contact.Key;

            lock (_contacts)
            {
                var target = _contacts.FirstOrDefault(x => x.Key == contact.Key);

                if (target == null)
                {
                    target     = ContactInfo.GetLocalObject(contact);
                    target.Key = Guid.NewGuid().ToString("D");
                    result     = target.Key;

                    _contacts.Add(target);
                }
                else
                {
                    _contacts.Remove(target);
                    _contacts.Add(ContactInfo.GetLocalObject(contact));
                }
            }

            FlushDb();

            return(result);
        }
Exemple #4
0
 public void NewElement(IContactInfo nc)
 {
     using (_lock.Write())
     {
         _list.Add(new Contact(nc.FirstName, nc.LastName, nc.Nickname, nc.Birthday, nc.Phone, nc.Email, nc.Mailer, nc.Note));
     }
 }
Exemple #5
0
 public Student(IContactInfo contactInfo, IEnumerable <IPresentation> presentations, IBook book, string teamName)
 {
     this.ContactInfo   = contactInfo;
     this.Presentations = presentations;
     this.Book          = book;
     this.Team          = teamName;
 }
        public ISecondaryContactHolder WithPrimaryContact(IContactInfo contact)
        {
            PersonBuilder builder = this.WithContact(contact);

            builder.PrimaryContact = contact;
            return(builder);
        }
 public bool Contains(IContactInfo contact)
 {
     return
         (this.EmailAddress.Equals(contact) ||
          this.PhoneNumber.Equals(contact) ||
          this.OtherContacts.Contains(contact));
 }
Exemple #8
0
 public void Update(IContactInfo data)
 {
     this.Title     = data.Title;
     this.FirstName = data.FirstName;
     this.LastName  = data.LastName;
     this.City      = data.City;
     this.CountryId = data.CountryId;
 }
        public async Task CalculateAsync_WhenCalled_ReturnsSameContactInfo()
        {
            IContactInfo sut = CreateSut();

            IContactInfo result = await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1));

            Assert.That(result, Is.SameAs(sut));
        }
Exemple #10
0
 public Person(string first, string last, DateTime dateOfBirth, IContactInfo contactInfo, IList <IClass> classes)
 {
     this.FirstName   = first;
     this.LastName    = last;
     this.DateOfBirth = dateOfBirth;
     this.ContactInfo = contactInfo;
     this.Classes     = classes;
 }
        public async Task CalculateAsync_WhenCalled_ReturnsSameContactInfoWhereStatusDateEqualDateFromCall()
        {
            IContactInfo sut = CreateSut();

            DateTime     statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1);
            IContactInfo result     = await sut.CalculateAsync(statusDate);

            Assert.That(result.StatusDate, Is.EqualTo(statusDate.Date));
        }
        public async Task CalculateAsync_WhenCalled_AssertPostingLineCollectionWasCalledOnContactAccount()
        {
            Mock <IContactAccount> contactAccountMock = _fixture.BuildContactAccountMock();
            IContactInfo           sut = CreateSut(contactAccountMock.Object);

            await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1));

            contactAccountMock.Verify(m => m.PostingLineCollection, Times.Once);
        }
Exemple #13
0
        public void Add(IContactInfo contact)
        {
            if (Contacts.Contains(contact))
            {
                throw new ArgumentException();
            }

            Contacts.Add(contact);
        }
 internal ContactInfo MapDtoToContactInfoEntity(IContactInfo dto)
 {
     return(new ContactInfo
     {
         Id = dto.ContactInfoId,
         Email = dto.Email,
         Telephone = dto.Telephone,
         Mobile = dto.Mobile
     });
 }
        public IContanctHolder WithSecondaryContact(IContactInfo contact)
        {
            if (Contacts.Contains(contact))
            {
                throw new ArgumentException();
            }

            Contacts.Add(contact);
            return(this);
        }
Exemple #16
0
 public Student
 (
     string first, string last, DateTime dateOfBirth, IContactInfo contactInfo, IList <IClass> classes,
     string programOfStudy, DegreeType degree
 )
     : base(first, last, dateOfBirth, contactInfo, classes)
 {
     this.ProgramOfStudy = programOfStudy;
     this.PursuedDegree  = degree;
 }
Exemple #17
0
        /// <summary>
        /// Inserts a new contact info into the DAL.
        /// </summary>
        /// <param name="data">DTO to create from</param>
        /// <returns>An ContactInfo DAL object</returns>
        /// <exception cref="System.ArgumentException">Errors in data will result in an exception being thrown</exception>
        public IContactInfo InsertContact(IContactInfo data)
        {
            var db          = new Context();
            var contactInfo = ContactInfo.CreateContactInfo(data);

            db.ContactInfoes.Add(contactInfo);

            db.SaveChanges();

            return(contactInfo);
        }
Exemple #18
0
 public ISecondaryContactHolder WithSecondaryContact(IContactInfo contact) =>
 new PersonBuilder()
 {
     FirstName = this.FirstName,
     LastName  = this.LastName,
     Contacts  = new List <IContactInfo>(this.Contacts)
     {
         contact
     },
     PrimaryContact = this.PrimaryContact
 };
 private PersonBuilder WithContact(IContactInfo contact) =>
 new PersonBuilder()
 {
     FirstName = this.FirstName,
     LastName  = this.LastName,
     Contacts  = new List <IContactInfo>(this.Contacts)
     {
         contact
     },
     PrimaryContact = this.PrimaryContact
 };
Exemple #20
0
 public void SetPrimaryContact(IContactInfo contact)
 {
     if (contact == null)
     {
         throw new ArgumentNullException();
     }
     if (!Contacts.Contains(contact))
     {
         throw new ArgumentException();
     }
     this.PrimaryContact = contact;
 }
 public ValidPrimaryContact(IContactInfo contact, Func <IContactInfo, bool> predicate)
 {
     if (contact == null || predicate == null)
     {
         throw new ArgumentNullException();
     }
     if (!predicate(contact))
     {
         throw new ArgumentException();
     }
     this.Contact   = contact;
     this.Predicate = predicate;
 }
Exemple #22
0
        public void Add(IContactInfo contact)
        {
            if (contact == null)
            {
                throw new ArgumentNullException();
            }

            if (this.Contacts.Contains(contact))
            {
                throw new ArgumentException();
            }

            this.Contacts.Add(contact);
        }
Exemple #23
0
 public ContactInfoModel(IContactInfo data)
 {
     this.Id             = data.ContactInfoId;
     this.Uid            = data.ContactInfoUid;
     this.Title          = data.Title;
     this.FirstName      = data.FirstName;
     this.LastName       = data.LastName;
     this.City           = data.City;
     this.Country        = CountryModel.Load(data.CountryId);
     this.DateCreated    = data.DateCreated;
     this.Addresses      = data.Addresses.Select(a_ => new AddressModel(a_)).ToList();
     this.EmailAddresses = data.EmailAddresses.Select(e_ => new EmailModel(e_)).ToList();
     this.PhoneNumbers   = data.PhoneNumbers.Select(p_ => new PhoneNumberModel(p_)).ToList();
 }
Exemple #24
0
 public ContactInfo(IContactInfo data)
 {
     ContactInfoId  = data.ContactInfoId;
     ContactInfoUid = data.ContactInfoUid;
     FirstName      = data.FirstName;
     LastName       = data.LastName;
     Title          = data.Title;
     DateCreated    = data.DateCreated;
     City           = data.City;
     CountryId      = data.CountryId;
     Addresses      = data.Addresses;
     PhoneNumbers   = data.PhoneNumbers;
     EmailAddresses = data.EmailAddresses;
 }
Exemple #25
0
        private static ContactInfo ConvertIContactInfoToContactInfo(IContactInfo contact)
        {
            var cnt = new ContactInfo {
                FirstName = contact.FirstName,
                LastName  = contact.LastName,
                Birthday  = contact.Birthday,
                Nickname  = contact.Nickname,
                Email     = contact.Email,
                Phone     = contact.Phone,
                Mailer    = contact.Mailer,
                Note      = contact.Note
            };

            return(cnt);
        }
Exemple #26
0
 public static void WriteIContactInfos(IContactInfo entity)
 {
     Console.WriteLine("IContactInfo");
     foreach (var item in entity.ContactInfos)
     {
         if (!string.IsNullOrEmpty(item.Phone))
         {
             Console.WriteLine($"Telefon: { item.Phone }");
         }
         else
         {
             Console.WriteLine($"Adres: { item.Address }");
         }
     }
     Console.WriteLine();
 }
Exemple #27
0
        public void SetPrimaryContact(IContactInfo contact)
        {   // NOTE: It would be better to throw if contact is not email address
            // but that requires a new Boolean method like IsValidPrimaryContact
            // so that code contract can be implemented properly

            EmailAddress emailAddress = contact as EmailAddress;

            if (emailAddress == null)
            {
                this.Owner.Add(contact);
            }
            else
            {
                this.Owner.SetEmailAddress(emailAddress);
            }
        }
        public async Task CalculateAsync_WhenCalled_AssertBalanceIsCalculated()
        {
            DateTime today           = DateTime.Today;
            DateTime calculationDate = DateTime.Today.AddMonths(_random.Next(1, 5) * -1).AddDays(today.Day * -1).AddDays(1);

            int year  = calculationDate.Year;
            int month = calculationDate.Month;

            decimal calculatedPostingValue = _fixture.Create <decimal>();
            IPostingLineCollection postingLineCollection = _fixture.BuildPostingLineCollectionMock(calculatedPostingValue: calculatedPostingValue).Object;
            IContactAccount        contactAccount        = _fixture.BuildContactAccountMock(postingLineCollection: postingLineCollection).Object;
            IContactInfo           sut = CreateSut(contactAccount, (short)year, (short)month);

            IContactInfo result = await sut.CalculateAsync(calculationDate);

            Assert.That(result.Balance, Is.EqualTo(calculatedPostingValue));
        }
Exemple #29
0
        /// <summary>
        /// Updates an existing contact.
        /// </summary>
        /// <param name="data">ContactInfo to update</param>
        /// <returns>An ContactInfo DTO object</returns>
        /// <exception cref="TooksCms.Core.Exceptions.DataNotFoundException">ContactInfo does not exist</exception>
        public IContactInfo UpdateContact(IContactInfo data)
        {
            var db = new Context();

            if (!_contactExists(data.ContactInfoId, db))
            {
                throw new DataNotFoundException("ContactInfo does not exits", "id");
            }

            var ci = db.ContactInfoes.First(ci_ => ci_.ContactInfoId == data.ContactInfoId);

            ci.Update(data);

            db.SaveChanges();

            return(ci);
        }
Exemple #30
0
 public void NewElement(IContactInfo contact)
 {
     Send(new XElement(XName.Get("request", this.Namespace),
                       new XElement(XName.Get("save", this.Namespace),
                                    new XElement(XName.Get("contact", this.Namespace),
                                                 new XElement(XName.Get("n", this.Namespace), contact.FirstName),
                                                 new XElement(XName.Get("fn", this.Namespace), contact.LastName),
                                                 new XElement(XName.Get("nick", this.Namespace), contact.Nickname),
                                                 new XElement(XName.Get("bday", this.Namespace), contact.Birthday),
                                                 new XElement(XName.Get("tel", this.Namespace), contact.Phone),
                                                 new XElement(XName.Get("email", this.Namespace), contact.Email),
                                                 new XElement(XName.Get("mailer", this.Namespace), contact.Mailer),
                                                 new XElement(XName.Get("note", this.Namespace), contact.Note)
                                                 )
                                    )
                       )
          );
 }
Exemple #31
0
        /// <summary>
        /// this is a deep copy
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        public static void CopyIContactInfo(IContactInfo from, IContactInfoM to)
        {
            if (from == null)
                throw new ArgumentNullException("the from is null");
            if (to == null)
                throw new ArgumentNullException("the to is null");
            if (from.Address == null)
                to.Address = null;
            else if (to.Address == null)
                throw new ArgumentNullException("the to.Address is null");
            else
                CopyIAddress(from.Address, to.Address);

            to.Company = from.Company;
            to.Email = from.Email;
            to.Fax = from.Fax;
            to.FirstName = from.Email;
            to.LastName = from.LastName;
            to.Phone = from.Phone;
        }
Exemple #32
0
 public void PrintName(IContactInfo ic)
 {
     Console.WriteLine(ic.Name);
 }
Exemple #33
0
 public void AddContact(IContactInfo contactInfo)
 {
     _rosterManager.AddRosterItem(new Jid(contactInfo.Name, contactInfo.Server, null));
 }
 public static void PrintContactInfo(IContactInfo contact)
 {
     Console.WriteLine("Type: {3} contact\nName: {0}\nAddress: {1}\nPhone: {2}",contact.Name,contact.Address,contact.Number,contact.GetType().Name);
 }