Example #1
0
        private CustomerModel Map(UploadedCustomer uploadedCustomer)
        {
            var model = new CustomerModel
            {
                CustomerId   = uploadedCustomer.CustomerId,
                FirstName    = uploadedCustomer.FirstName,
                LastName     = uploadedCustomer.LastName,
                EmailAddress = uploadedCustomer.EmailAddress != null ? uploadedCustomer.EmailAddress.Address : null
            };

            return model;
        }
Example #2
0
        public void GetFacebookContacts(string authToken)
        {
            ResetUploadedCustomers();

            var friendsList = new List<UploadedCustomer>();

            _fbAuth.AccessTokenGet(authToken, _appSettings.GetValue(FacebookConfigKey));

            if (_fbAuth.Token.Length > 0)
            {
                var query = "SELECT uid, first_name, middle_name, last_name, pic_big_with_logo, email, profile_url, birthday_date, languages FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY last_name";

                var response = _fbAuth.FQLWebRequest(Method.GET, query, string.Empty);

                var fbObj = FacebookObject.CreateFromString(response);
                var friends = fbObj.Dictionary["data"].Array;

                foreach (var friend in friends)
                {
                    if (friend.IsDictionary)
                    {
                        var dict = friend.Dictionary;

                        var newFriend = new UploadedCustomer();
                        newFriend.ContactInformation.FirstName = dict["first_name"].String;
                        newFriend.ContactInformation.MiddleName = dict["middle_name"].String;
                        newFriend.ContactInformation.LastName = dict["last_name"].String;
                        if (!string.IsNullOrEmpty(dict["pic_big_with_logo"].String))
                            newFriend.ExternalPictureUrl = dict["pic_big_with_logo"].String;

                        if (!string.IsNullOrEmpty(dict["email"].String))
                        {
                            var newEmail = new Quartet.Entities.EmailAddress();
                            newEmail.Address = dict["email"].String;
                            newEmail.EmailAddressStatus = Quartet.Entities.EmailAddressStatus.Valid;
                            newFriend.EmailAddress = newEmail;
                        }

                        if (dict["birthday_date"].String != null)
                        {
                            var birthDate = DateTime.Parse(dict["birthday_date"].String);
                            var newDate = new Quartet.Entities.SpecialOccasion();
                            newDate.SpecialOccasionKey = Guid.NewGuid();
                            newDate.Day = Convert.ToByte(birthDate.Day);
                            newDate.Month = Convert.ToByte(birthDate.Month);
                            newDate.Year = Convert.ToInt16(birthDate.Year);
                            newDate.SpecialOccasionType = Quartet.Entities.SpecialOccasionType.Birthday;
                            newFriend.SpecialOccasions.Add(Quartet.Entities.SpecialOccasionType.Anniversary, newDate);
                        }

                        if (dict["profile_url"].String != null)
                        {
                            var newLink = new Quartet.Entities.HyperLink();
                            newLink.HyperLinkKey = Guid.NewGuid();
                            newLink.HyperLinkType = Quartet.Entities.HyperLinkType.Facebook;
                            var newUri = new Uri(dict["profile_url"].String);
                            newLink.Url = newUri;
                            newFriend.Hyperlinks.Add(Quartet.Entities.HyperLinkType.Facebook, newLink);
                        }

                        friendsList.Add(newFriend);
                    }
                }
            }

            if (friendsList != null && friendsList.Count > 0)
                SetUploadedCustomers(friendsList);
        }