public void addFacebookInsightPostStats(FacebookInsightPostStats fbinsightstats)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             session.Save(fbinsightstats);
             transaction.Commit();
         }
     }
 }
 /// <addFacebookInsightPostStats>
 /// Add a new facebook insight post stats
 /// </summary>
 /// <param name="fbinsightstats">Set Values in a FacebookInsightPostStats Class Property and Pass the same Object of FacebookInsightPostStats Class as a parameter (SocioBoard.Domain.FacebookInsightPostStats).</param>
 public void addFacebookInsightPostStats(FacebookInsightPostStats fbinsightstats)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //Begin session trasaction and opens up.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action, to save a new data.
             session.Save(fbinsightstats);
             transaction.Commit();
         }//End Trsaction
     }//End session
 }
        public void getFanPost(string pageId, Guid UserId, int days)
        {
            string strStories = "https://graph.facebook.com/" + pageId + "/feed";
            FacebookClient fb = new FacebookClient();
            FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
            FacebookAccount acc = fbAccRepo.getUserDetails(pageId);
            fb.AccessToken = acc.AccessToken;
            JsonObject outputreg = (JsonObject)fb.Get(strStories);
            JArray data = (JArray)JsonConvert.DeserializeObject(outputreg["data"].ToString());
            FacebookInsightPostStats objFbiPost = new FacebookInsightPostStats();
            FacebookInsightPostStatsRepository objfbiPostRepo = new FacebookInsightPostStatsRepository();

            foreach (var item in data)
            {

                try
                {
                    objFbiPost.Id = Guid.NewGuid();
                    objFbiPost.EntryDate = DateTime.Now;
                    objFbiPost.PageId = pageId;
                    try
                    {
                        objFbiPost.PostMessage = item["story"].ToString();
                    }
                    catch (Exception Err)
                    {
                        objFbiPost.PostMessage = item["message"].ToString();
                    }
                    objFbiPost.PostDate = item["created_time"].ToString();
                    JArray arrComment = (JArray)item["comment"];
                    if (arrComment != null)
                        objFbiPost.PostComments = arrComment.Count;
                    else
                        objFbiPost.PostComments = 0;
                    objFbiPost.PostId = item["id"].ToString();
                    objFbiPost.UserId = UserId;
                    if (!objfbiPostRepo.checkFacebookInsightPostStatsExists(pageId, item["id"].ToString(), UserId, item["created_time"].ToString()))
                        objfbiPostRepo.addFacebookInsightPostStats(objFbiPost);
                    else
                        objfbiPostRepo.updateFacebookInsightPostStats(objFbiPost);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

        }
 public void updateFacebookInsightPostStats(FacebookInsightPostStats fbaccount)
 {
     throw new NotImplementedException();
 }