Beispiel #1
0
        private int AddRelationShips(GoogleContact googleContact, int nextRelationshipId, int nextContactId)
        {
            if (!string.IsNullOrEmpty(googleContact.Relation1Value))
            {
                var relationShip = new Relationship
                {
                    Id        = nextRelationshipId,
                    ContactId = nextContactId,
                    Person    = googleContact.Relation1Value,
                    Type      = googleContact.Relation1Type
                };
                _db.Relationships.Add(relationShip);
                nextRelationshipId++;
            }

            if (!string.IsNullOrEmpty(googleContact.Relation2Value))
            {
                var relationShip = new Relationship
                {
                    Id        = nextRelationshipId,
                    ContactId = nextContactId,
                    Person    = googleContact.Relation2Value,
                    Type      = googleContact.Relation2Type
                };
                _db.Relationships.Add(relationShip);
                nextRelationshipId++;
            }

            if (!string.IsNullOrEmpty(googleContact.Relation3Value))
            {
                var relationShip = new Relationship
                {
                    Id        = nextRelationshipId,
                    ContactId = nextContactId,
                    Person    = googleContact.Relation3Value,
                    Type      = googleContact.Relation3Type
                };
                _db.Relationships.Add(relationShip);
                nextRelationshipId++;
            }

            if (!string.IsNullOrEmpty(googleContact.Relation4Value))
            {
                var relationShip = new Relationship
                {
                    Id        = nextRelationshipId,
                    ContactId = nextContactId,
                    Person    = googleContact.Relation4Value,
                    Type      = googleContact.Relation4Type
                };
                _db.Relationships.Add(relationShip);
                nextRelationshipId++;
            }

            return(nextRelationshipId);
        }
Beispiel #2
0
        private void CreateContact(int nextContactId, GoogleContact googleContact, string imagePath)
        {
            var newContact = new Contact
            {
                Id            = nextContactId,
                Firstname     = googleContact.GivenName,
                Middlename    = googleContact.AdditionalName,
                Lastname      = googleContact.FamilyName,
                Address       = googleContact.Address1Formatted,
                BusinessTitle = googleContact.Organization1Title,
                Employer      = googleContact.Organization1Name,
                ImagePath     = imagePath
            };

            _db.Contacts.Add(newContact);
        }
Beispiel #3
0
        private int AddStatusUpdate(GoogleContact googleContact, int nextStatusUpdateId, int nextContactId)
        {
            if (!string.IsNullOrEmpty(googleContact.Notes))
            {
                var statusUpdate = new StatusUpdate
                {
                    Id         = nextStatusUpdateId,
                    Created    = DateTime.Now,
                    ContactId  = nextContactId,
                    StatusText = googleContact.Notes
                };
                _db.StatusUpdates.Add(statusUpdate);
                nextStatusUpdateId++;
            }

            return(nextStatusUpdateId);
        }
Beispiel #4
0
        private int AddEmails(GoogleContact googleContact, int nextContactId, int nextMailId)
        {
            if (!string.IsNullOrEmpty(googleContact.Email1Value))
            {
                var mail1 = new EmailAddress
                {
                    Id        = nextMailId,
                    ContactId = nextContactId,
                    Email     = googleContact.Email1Value,
                    Type      = googleContact.Email1Type
                };
                _db.EmailAddresses.Add(mail1);
                nextMailId++;
            }

            if (!string.IsNullOrEmpty(googleContact.Email2Value))
            {
                var mail2 = new EmailAddress
                {
                    Id        = nextMailId,
                    ContactId = nextContactId,
                    Email     = googleContact.Email2Value,
                    Type      = googleContact.Email2Type
                };
                _db.EmailAddresses.Add(mail2);
                nextMailId++;
            }

            if (!string.IsNullOrEmpty(googleContact.Email3Value))
            {
                var mail3 = new EmailAddress
                {
                    Id        = nextMailId,
                    ContactId = nextContactId,
                    Email     = googleContact.Email3Value,
                    Type      = googleContact.Email3Type
                };
                _db.EmailAddresses.Add(mail3);
                nextMailId++;
            }

            return(nextMailId);
        }
Beispiel #5
0
        private int AddPhoneNumbers(GoogleContact googleContact, int nextPhoneId, int nextContactId)
        {
            if (!string.IsNullOrEmpty(googleContact.Phone1Value))
            {
                var phone = new TelephoneNumber
                {
                    Id        = nextPhoneId,
                    ContactId = nextContactId,
                    Telephone = googleContact.Phone1Value,
                    Type      = googleContact.Phone1Type
                };
                _db.TelephoneNumbers.Add(phone);
                nextPhoneId++;
            }

            if (!string.IsNullOrEmpty(googleContact.Phone2Value))
            {
                var phone = new TelephoneNumber
                {
                    Id        = nextPhoneId,
                    ContactId = nextContactId,
                    Telephone = googleContact.Phone2Value,
                    Type      = googleContact.Phone2Type
                };
                _db.TelephoneNumbers.Add(phone);
                nextPhoneId++;
            }

            if (!string.IsNullOrEmpty(googleContact.Phone3Value))
            {
                var phone = new TelephoneNumber
                {
                    Id        = nextPhoneId,
                    ContactId = nextContactId,
                    Telephone = googleContact.Phone3Value,
                    Type      = googleContact.Phone3Type
                };
                _db.TelephoneNumbers.Add(phone);
                nextPhoneId++;
            }

            return(nextPhoneId);
        }
Beispiel #6
0
        private string GetImagePath(GoogleContact googleContact, int nextContactId)
        {
            var imagePath = "/images/contacts/unknown.png";

            if (string.IsNullOrEmpty(googleContact.Photo))
            {
                return(imagePath);
            }

            try
            {
                imagePath = SaveImage(googleContact.Photo, nextContactId);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Image '{googleContact.Photo}' could not be downloaded. " + e.Message);
            }

            return(imagePath);
        }