public void GetUserSites(string UserId, string WpUserId)
        {
            Domain.Myfashion.Domain.WordpressAccount objWordpressAccount = new Domain.Myfashion.Domain.WordpressAccount();

            objWordpressAccount = objWPAccountRepo.GetWordpressAccountById(Guid.Parse(UserId), WpUserId);
            oAuthWordpress _oAuth = new oAuthWordpress();

            _oAuth.access_token = objWordpressAccount.AccessToken;
            string  usersites = _oAuth.APIWebRequestToGetUserInfo(Globals._UserSites);
            JObject User_Site = JObject.Parse(usersites);
            var     Site_Data = User_Site["sites"];

            foreach (var site in Site_Data)
            {
                Domain.Myfashion.Domain.WordpressSites objWordpressSites = new Domain.Myfashion.Domain.WordpressSites();
                objWordpressSites.Id                = Guid.NewGuid();
                objWordpressSites.SiteId            = site["ID"].ToString();
                objWordpressSites.SiteName          = site["name"].ToString();
                objWordpressSites.Description       = site["description"].ToString();
                objWordpressSites.Post_Count        = site["post_count"].ToString();
                objWordpressSites.Subscribers_Count = site["subscribers_count"].ToString();
                objWordpressSites.SiteURL           = site["URL"].ToString();
                objWordpressSites.UserId            = Guid.Parse(UserId);
                objWordpressSites.WPUserId          = WpUserId;
                objWordpressSites.CreatedTime       = DateTime.Parse(site["options"]["created_at"].ToString());
                objWordpressSites.EntryTime         = DateTime.Now;
                if (!objWordpressSitesRepository.IsSiteAllreadyExist(objWordpressSites.UserId, objWordpressSites.WPUserId, objWordpressSites.SiteId))
                {
                    objWordpressSitesRepository.AddWordpressSites(objWordpressSites);
                }
                GetUserFeedBySite(UserId, objWordpressSites.WPUserId, objWordpressSites.SiteId, objWordpressAccount.AccessToken);
            }
        }
Exemple #2
0
 public void AddWordpressSites(Domain.Myfashion.Domain.WordpressSites _WordpressSites)
 {
     //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())
         {
             //Proceed action, to save data.
             session.Save(_WordpressSites);
             transaction.Commit();
         } // End Using Trasaction
     }     // End using session
 }
 public string GetSiteBySiteId(string UserId, string SiteId)
 {
     Domain.Myfashion.Domain.WordpressSites _WordpressSites = objWordpressSitesRepository.GetSiteBySiteId(Guid.Parse(UserId), SiteId);
     return(new JavaScriptSerializer().Serialize(_WordpressSites));
 }
 public void GetUserSites(string UserId, string WpUserId)
 {
     Domain.Myfashion.Domain.WordpressAccount objWordpressAccount = new Domain.Myfashion.Domain.WordpressAccount();
     
     objWordpressAccount = objWPAccountRepo.GetWordpressAccountById(Guid.Parse(UserId), WpUserId);
     oAuthWordpress _oAuth = new oAuthWordpress();
     _oAuth.access_token = objWordpressAccount.AccessToken;
     string usersites = _oAuth.APIWebRequestToGetUserInfo(Globals._UserSites);
     JObject User_Site = JObject.Parse(usersites);
     var Site_Data = User_Site["sites"];
     foreach (var site in Site_Data)
     {
         Domain.Myfashion.Domain.WordpressSites objWordpressSites = new Domain.Myfashion.Domain.WordpressSites();
         objWordpressSites.Id = Guid.NewGuid();
         objWordpressSites.SiteId = site["ID"].ToString();
         objWordpressSites.SiteName = site["name"].ToString();
         objWordpressSites.Description = site["description"].ToString();
         objWordpressSites.Post_Count = site["post_count"].ToString();
         objWordpressSites.Subscribers_Count = site["subscribers_count"].ToString();
         objWordpressSites.SiteURL = site["URL"].ToString();
         objWordpressSites.UserId = Guid.Parse(UserId);
         objWordpressSites.WPUserId = WpUserId;
         objWordpressSites.CreatedTime = DateTime.Parse(site["options"]["created_at"].ToString());
         objWordpressSites.EntryTime = DateTime.Now;
         if (!objWordpressSitesRepository.IsSiteAllreadyExist(objWordpressSites.UserId, objWordpressSites.WPUserId, objWordpressSites.SiteId))
         {
             objWordpressSitesRepository.AddWordpressSites(objWordpressSites);
         }
         GetUserFeedBySite(UserId, objWordpressSites.WPUserId, objWordpressSites.SiteId, objWordpressAccount.AccessToken);
     }
 }