public static void InstagramLikeUnLike(int LikeCount, int IsLike, string FeedId, string InstagramId, long groupId, Helper.AppSettings _appSettings, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            MongoRepository instagramFeedRepo = new MongoRepository("InstagramFeed", _appSettings);

            Domain.Socioboard.Models.Instagramaccounts _Instagramaccounts = Repositories.InstagramRepository.getInstagramAccount(InstagramId, _redisCache, dbr);
            LikesController objlikes = new LikesController();

            if (IsLike == 1)
            {
                LikeCount = LikeCount - 1;
                IsLike    = 0;
                bool ret = objlikes.DeleteLike(FeedId, _Instagramaccounts.AccessToken);
            }
            else
            {
                LikeCount = LikeCount + 1;
                IsLike    = 1;
                bool ret = objlikes.PostUserLike(FeedId, _Instagramaccounts.AccessToken);
            }

            FilterDefinition <BsonDocument> filter = new BsonDocument("FeedId", FeedId);
            var update = Builders <BsonDocument> .Update.Set("IsLike", IsLike).Set("LikeCount", LikeCount);

            instagramFeedRepo.Update <Domain.Socioboard.Models.Mongo.InstagramFeed>(update, filter);
        }
Пример #2
0
        public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId)
        {
            string str = string.Empty;

            try
            {
                objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId));

                LikesController objlikes   = new LikesController();
                int             islike     = Convert.ToInt32(IsLike);
                int             LikeCounts = Convert.ToInt32(LikeCount);

                if (islike == 0)
                {
                    islike = 1;
                    bool dd = objlikes.PostUserLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts++;
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "unlike";
                }
                else
                {
                    islike = 0;
                    bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts = LikeCounts - 1;
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "like";
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return(str);
        }
Пример #3
0
        public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId)
        {
            string str = string.Empty;

            GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = new oAuthInstagram();

            _api = oAuthInstagram.GetInstance(configi);
            try
            {
                objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId));

                LikesController objlikes   = new LikesController();
                int             islike     = Convert.ToInt32(IsLike);
                int             LikeCounts = Convert.ToInt32(LikeCount);

                if (islike == 0)
                {
                    islike = 1;
                    bool dd = objlikes.PostUserLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts++;
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "unlike";
                }
                else
                {
                    islike = 0;
                    bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts = LikeCounts - 1;
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "like";
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return(str);
        }