Exemple #1
0
        internal void ValidateSaveFBFriends(FBFriends fbfriends)
        {
            if (fbfriends == null)
            {
                AddError(ErrorCode.INVALID_FRIENDS);
            }
            foreach (FBFriend friend in fbfriends.Friends)
            {
                if (friend == null)
                {
                    AddError(ErrorCode.INVALID_FRIEND);
                }
                if (friend.id.Equals(Zero))
                {
                    AddError(ErrorCode.FBFRIEND_NOT_VALID, friend.Name);
                }
            }

            if (NoErrors)
            {
                return;
            }

            throw ClientException;
        }
Exemple #2
0
        public bool SaveFBFriends(FBFriends fbFriends)
        {
            IVizFBService service = ObjectFactory.Resolve <IVizFBService>();

            service.SaveFBFriends(fbFriends);
            return(true);
        }
Exemple #3
0
        public bool SaveFBFriends(FBFriends fbFriends)
        {
            FBUser User = AppRequestContext.FBUser;

            long userId = CheckFBUser(User);

            return(SaveFBFriends(fbFriends, userId));
        }
Exemple #4
0
        private bool SaveFBFriends(FBFriends fbFriends, long userId)
        {
            try
            {
                bool   isFriendAdded = false;
                string query         = string.Empty;
                Dictionary <string, object> queryparams = null;
                long friendId = 0;

                foreach (FBFriend friend in fbFriends.Friends)
                {
                    friendId      = CheckFriend(friend);
                    isFriendAdded = (friendId > 0);
                    query         = isFriendAdded ?
                                    VizFBQueries.UPDATE_FB_FRIEND_DETAILS : VizFBQueries.SAVE_FB_FRIEND_DETAILS;
                    queryparams = new Dictionary <string, object>();
                    queryparams.Add("@fb_id", friend.id);
                    queryparams.Add("@image_url", friend.ImageURL);
                    queryparams.Add("@name", friend.Name);
                    queryparams.Add("@email", friend.Email);
                    queryparams.Add("@phone", friend.PhoneNumber);
                    queryparams.Add("@profile_url", friend.ProfileURL);
                    queryparams.Add("@lat", friend.Lat);
                    queryparams.Add("@lng", friend.Lng);
                    queryparams.Add("@selected", friend.Selected);

                    if (!isFriendAdded)
                    {
                        friendId = ExecuteNonQueryWithOutputParam(query, ConvertToDBParameters(queryparams));
                    }
                    else
                    {
                        ExecuteNonQuery(query, ConvertToDBParameters(queryparams));
                    }

                    if (!isFriendAdded)
                    {
                        MapUserFriend(userId, friendId);
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                Logger.Error(e.Message);
                throw new AppException(ErrorCode.SQL_GENERAL_ERROR);
            }
        }
Exemple #5
0
        private void btUpdateFriends_Click(object sender, EventArgs e)
        {
            string    url     = "/api/VizFriends/UpdateSelectedFriends";
            FBFriends Friends = new FBFriends
            {
                Friends = new List <FBFriend>
                {
                    new FBFriend()
                    {
                        id          = "1725371",
                        Email       = "*****@*****.**",
                        ImageURL    = "http://graph.facebook.com/t/img_67853.jpg",
                        Lat         = "12.523623",
                        Lng         = "20.254624",
                        Name        = "Santhosh",
                        PhoneNumber = "1823967563",
                        ProfileURL  = "http://facebook.com/sandy",
                        Selected    = false
                    },
                    new FBFriend()
                    {
                        id          = "1725372",
                        Email       = "*****@*****.**",
                        ImageURL    = "http://graph.facebook.com/t/img_724873.jpg",
                        Lat         = "12.553623",
                        Lng         = "20.256624",
                        Name        = "Praveen",
                        PhoneNumber = "1823912154",
                        ProfileURL  = "http://facebook.com/sexy",
                        Selected    = true
                    }
                }
            };
            List <FBFriend> frnds = new List <FBFriend>();

            frnds.Add(CreateFriend("537462998", "Rakesh Ks", "https://m.ak.fbcdn.net/profile.ak/hprofile-ak-ash3/t5/370187_537462998_1257659137_q.jpg", "http://facebook.com/Rakesh Ks", "12.12", "12.12", "Rakesh [email protected]", "3467738468", false));
            frnds.Add(CreateFriend("610332030", "Donn Kabiraj", "https://m.ak.fbcdn.net/profile.ak/hprofile-ak-ash3/t5/623595_610332030_1326593215_q.jpg", "http://facebook.com/Donn Kabiraj", "12.12", "12.12", "Donn [email protected]", "3467738468", false));
            Friends.Friends = frnds;
            bool result = InvokeService <FBFriends>(Friends, url, "POST", false, false);
        }
Exemple #6
0
        public bool UpdateSelectedFriends(FBFriends fbFriends)
        {
            try
            {
                Dictionary <int, string>    settings    = DefaultSettings;
                Dictionary <string, object> queryparams = null;
                foreach (FBFriend friend in fbFriends.Friends)
                {
                    queryparams = new Dictionary <string, object>();
                    queryparams.Add("@selected", friend.Selected);
                    queryparams.Add("@fb_id", friend.id);

                    ExecuteNonQuery(VizFriendsQueries.UPDATE_SELECTED_FRIEND,
                                    ConvertToDBParameters(queryparams));
                }
                return(true);
            }
            catch (Exception e)
            {
                Logger.Error(e.Message);
                throw new AppException(ErrorCode.SQL_GENERAL_ERROR);
            }
        }
Exemple #7
0
        public bool UpdateSelectedFriends(FBFriends fbFriends)
        {
            IVizFriendsService service = ObjectFactory.Resolve <IVizFriendsService>();

            return(service.UpdateSelectedFriends(fbFriends));
        }
Exemple #8
0
 public bool UpdateSelectedFriends(FBFriends fbFriends)
 {
     new VizFriendsValidator().ValidateSelectedFriends(fbFriends);
     return(dao.UpdateSelectedFriends(fbFriends));
 }
Exemple #9
0
 public bool SaveFBFriends(FBFriends fbFriends)
 {
     new VizFBValidator().ValidateSaveFBFriends(fbFriends);
     return(dao.SaveFBFriends(fbFriends));
 }