Esempio n. 1
0
 public void updateLinkedinPostofPage(Domain.Myfashion.Domain.LinkedinCompanyPagePosts lipost)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 session.CreateQuery("Update LinkedinCompanyPagePosts set Likes =:Likes,Comments =:Comments,IsLiked=:IsLiked where PostId = :PostId and UserId = :UserId")
                 .SetParameter("Likes", lipost.Likes)
                 .SetParameter("Comments", lipost.Comments)
                 .SetParameter("IsLiked", lipost.IsLiked)
                 .SetParameter("PostId", lipost.PostId)
                 .SetParameter("UserId", lipost.UserId)
                 .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         }
     }
 }
Esempio n. 2
0
 public void addLinkedInPagepost(Domain.Myfashion.Domain.LinkedinCompanyPagePosts lipost)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             session.Save(lipost);
             transaction.Commit();
         } //End Transaction
     }     //End Session
 }
        public void GetLinkedinCompanyPageFeeds(oAuthLinkedIn _oauth, string UserId, string PageId)
        {
            LinkedinPageUpdate objlinkedinpageupdate = new LinkedinPageUpdate();
            LinkedinPagePostRepository objlipagepostRepo = new LinkedinPagePostRepository();
            List<LinkedinPageUpdate.CompanyPagePosts> objcompanypagepost = new List<LinkedinPageUpdate.CompanyPagePosts>();
            objcompanypagepost = objlinkedinpageupdate.GetPagePosts(_oauth, PageId);
            LinkedinCompanyPagePosts lipagepost = new LinkedinCompanyPagePosts();
            foreach (var item in objcompanypagepost)
            {
                lipagepost.Id = Guid.NewGuid();
                lipagepost.Posts = item.Posts;
                lipagepost.PostDate = Convert.ToDateTime(item.PostDate);
                lipagepost.EntryDate = DateTime.Now;
                lipagepost.UserId = Guid.Parse(UserId);
                lipagepost.Type = item.Type;
                lipagepost.PostId = item.PostId;
                lipagepost.UpdateKey = item.UpdateKey;
                lipagepost.PageId = PageId;
                lipagepost.PostImageUrl = item.PostImageUrl;
                lipagepost.Likes = item.Likes;
                lipagepost.Comments = item.Comments;
                if (!objlipagepostRepo.checkLinkedInPostExists(lipagepost.PostId, lipagepost.UserId))
                {
                    objlipagepostRepo.addLinkedInPagepost(lipagepost);
                }
                else
                {
                    objlipagepostRepo.updateLinkedinPostofPage(lipagepost);
                }

            }
        }