public static string AddInstagramComment(string FeedId, string Text, string InstagramId, long groupId, Helper.AppSettings _appSettings, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            MongoRepository instagarmCommentRepo = new MongoRepository("InstagramComment", _appSettings);
            MongoRepository instagramFeedRepo    = new MongoRepository("InstagramFeed", _appSettings);

            Domain.Socioboard.Models.Mongo.InstagramComment _InstagramComment  = new Domain.Socioboard.Models.Mongo.InstagramComment();
            Domain.Socioboard.Models.Instagramaccounts      _Instagramaccounts = Repositories.InstagramRepository.getInstagramAccount(InstagramId, _redisCache, dbr);
            CommentController objComment = new CommentController();
            string            ret        = objComment.PostCommentAdd(FeedId, Text, _Instagramaccounts.AccessToken);

            if (!string.IsNullOrEmpty(ret))
            {
                try
                {
                    JObject JData      = JObject.Parse(ret);
                    string  commentid  = JData["data"]["id"].ToString();
                    string  time       = JData["data"]["created_time"].ToString();
                    string  profilepic = JData["data"]["from"]["profile_picture"].ToString();
                    string  username   = JData["data"]["from"]["username"].ToString();
                    _InstagramComment.Id             = ObjectId.GenerateNewId();
                    _InstagramComment.strId          = ObjectId.GenerateNewId().ToString();
                    _InstagramComment.FeedId         = FeedId;
                    _InstagramComment.InstagramId    = InstagramId;
                    _InstagramComment.FromProfilePic = profilepic;
                    _InstagramComment.FromName       = username;
                    _InstagramComment.CommentDate    = Convert.ToDouble(time);
                    _InstagramComment.Comment        = Text;
                    _InstagramComment.CommentId      = commentid;
                    instagarmCommentRepo.Add <Domain.Socioboard.Models.Mongo.InstagramComment>(_InstagramComment);

                    var retcomment = instagramFeedRepo.Find <Domain.Socioboard.Models.Mongo.InstagramFeed>(t => t.FeedId == FeedId);
                    var task       = Task.Run(async() => {
                        return(await retcomment);
                    });
                    List <Domain.Socioboard.Models.Mongo.InstagramFeed> lstfeed = task.Result.ToList();
                    Domain.Socioboard.Models.Mongo.InstagramFeed        feed    = lstfeed.First();
                    feed.CommentCount = feed.CommentCount + 1;
                    FilterDefinition <BsonDocument> filter = new BsonDocument("FeedId", FeedId);
                    var update = Builders <BsonDocument> .Update.Set("CommentCount", feed.CommentCount);

                    instagramFeedRepo.Update <Domain.Socioboard.Models.Mongo.InstagramFeed>(update, filter);
                    return("comment");
                }
                catch (Exception ex)
                {
                    return("");
                }
            }
            else
            {
                return("");
            }
        }
        public static void GetInstagramSelfFeeds(string instagramId, string accessToken, Helper.AppSettings _appSettings)
        {
            MongoRepository instagarmCommentRepo = new MongoRepository("InstagramComment", _appSettings);
            MongoRepository instagramFeedRepo    = new MongoRepository("InstagramFeed", _appSettings);

            try
            {
                Users userInstagram = new Users();
                Media _Media        = new Media();
                InstagramResponse <Comment[]> usercmts   = new InstagramResponse <Comment[]>();
                CommentController             objComment = new CommentController();
                LikesController objLikes = new LikesController();
                string          feeds    = _Media.UserResentFeeds(instagramId, accessToken);
                if (feeds != null)
                {
                    JObject feed_data = JObject.Parse(feeds);

                    foreach (var item in feed_data["data"])
                    {
                        try
                        {
                            Domain.Socioboard.Models.Mongo.InstagramFeed objInstagramFeed = new Domain.Socioboard.Models.Mongo.InstagramFeed();
                            try
                            {
                                objInstagramFeed.FeedDate = Convert.ToDouble(item["created_time"].ToString());
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FeedId = item["id"].ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.Type = item["type"].ToString();
                                if (objInstagramFeed.Type == "video")
                                {
                                    objInstagramFeed.VideoUrl = item["videos"]["standard_resolution"]["url"].ToString();
                                }
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FeedImageUrl = item["images"]["standard_resolution"]["url"].ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.InstagramId = instagramId;
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.LikeCount = Int32.Parse(item["likes"]["count"].ToString());
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.CommentCount = Int32.Parse(item["comments"]["count"].ToString());
                            }
                            catch { }
                            try
                            {
                                string str = item["user_has_liked"].ToString();
                                if (str.ToLower() == "false")
                                {
                                    objInstagramFeed.IsLike = 0;
                                }
                                else
                                {
                                    objInstagramFeed.IsLike = 1;
                                }
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.AdminUser = item["user"]["username"].ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.Feed = item["caption"]["text"].ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.ImageUrl = item["user"]["profile_picture"].ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FromId = item["user"]["id"].ToString();
                            }
                            catch { }
                            try
                            {
                                objInstagramFeed.FeedUrl = item["link"].ToString();
                            }
                            catch { }

                            var ret  = instagramFeedRepo.Find <Domain.Socioboard.Models.Mongo.InstagramFeed>(t => t.FeedId.Equals(objInstagramFeed.FeedId) && t.InstagramId.Equals(objInstagramFeed.InstagramId));
                            var task = Task.Run(async() =>
                            {
                                return(await ret);
                            });
                            int count = task.Result.Count;

                            if (count < 1)
                            {
                                instagramFeedRepo.Add(objInstagramFeed);
                            }
                            else
                            {
                                FilterDefinition <BsonDocument> filter = new BsonDocument("FeedId", objInstagramFeed.FeedId);
                                var update = Builders <BsonDocument> .Update.Set("IsLike", objInstagramFeed.IsLike).Set("CommentCount", objInstagramFeed.CommentCount).Set("LikeCount", objInstagramFeed.LikeCount).Set("Type", objInstagramFeed.Type).Set("VideoUrl", objInstagramFeed.VideoUrl);

                                instagramFeedRepo.Update <Domain.Socioboard.Models.Mongo.InstagramFeed>(update, filter);
                            }
                            List <Domain.Socioboard.Models.Mongo.InstagramComment> lstInstagramComment = new List <Domain.Socioboard.Models.Mongo.InstagramComment>();
                            usercmts = objComment.GetComment(objInstagramFeed.FeedId, accessToken);
                            for (int cmt = 0; cmt < usercmts.data.Count(); cmt++)
                            {
                                try
                                {
                                    Domain.Socioboard.Models.Mongo.InstagramComment objInstagramComment = new Domain.Socioboard.Models.Mongo.InstagramComment();
                                    try
                                    {
                                        objInstagramComment.Comment = usercmts.data[cmt].text;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.CommentDate = Convert.ToDouble(usercmts.data[cmt].created_time.ToString());
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.CommentId = usercmts.data[cmt].id;
                                    }
                                    catch { }

                                    try
                                    {
                                        objInstagramComment.FeedId = objInstagramFeed.FeedId;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.InstagramId = instagramId;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.FromName = usercmts.data[cmt].from.username;
                                    }
                                    catch { }
                                    try
                                    {
                                        objInstagramComment.FromProfilePic = usercmts.data[cmt].from.profile_picture;
                                    }
                                    catch { }

                                    lstInstagramComment.Add(objInstagramComment);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            instagarmCommentRepo.AddList(lstInstagramComment);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }