public Domain.Myfashion.Domain.LinkedinCompanyPage getCompanyPageInformation(Guid userid, string lipageid)
 {
     //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())
         {
             try
             {
                 //Proceed action, to get details of account.
                 NHibernate.IQuery query = session.CreateQuery("from LinkedinCompanyPage where LinkedinPageId = :LinkedinPageId And UserId=:UserId");
                 query.SetParameter("UserId", userid);
                 query.SetParameter("LinkedinPageId", lipageid);
                 Domain.Myfashion.Domain.LinkedinCompanyPage result = query.UniqueResult <Domain.Myfashion.Domain.LinkedinCompanyPage>();
                 return(result);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(null);
             }
         } //End Transaction
     }     //End Session
 }
 public Domain.Myfashion.Domain.LinkedinCompanyPage getCompanyPageInformation(string liPageid)
 {
     //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())
         {
             try
             {
                 //Proceed action, to get details of account.
                 List <Domain.Myfashion.Domain.LinkedinCompanyPage> objlst = session.CreateQuery("from LinkedinCompanyPage where LinkedinPageId = :linkedinpageid ")
                                                                             .SetParameter("linkedinpageid", liPageid)
                                                                             .List <Domain.Myfashion.Domain.LinkedinCompanyPage>().ToList <Domain.Myfashion.Domain.LinkedinCompanyPage>();
                 Domain.Myfashion.Domain.LinkedinCompanyPage result = new Domain.Myfashion.Domain.LinkedinCompanyPage();
                 if (objlst.Count > 0)
                 {
                     result = objlst[0];
                 }
                 return(result);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(null);
             }
         } //End Transaction
     }     //End Session
 }
        public string PutLikeOnLinkedinCompanyPageUpdate(string UserId, string PageId, string Updatekey, string IsLike)
        {
            try
            {
                string msg = string.Empty;

                int isLike = Convert.ToInt16(IsLike);

                if (isLike == 1)
                {
                    msg = "false";
                }
                else
                {
                    msg = "true";
                }

                Domain.Myfashion.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Myfashion.Domain.LinkedinCompanyPage();
                objlicompanypage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(PageId);
                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                Linkedin_oauth.Verifier    = objlicompanypage.OAuthVerifier;
                Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret;
                Linkedin_oauth.Token       = objlicompanypage.OAuthToken;
                Linkedin_oauth.Id          = objlicompanypage.LinkedinPageId;
                Linkedin_oauth.FirstName   = objlicompanypage.LinkedinPageName;
                Company company = new Company();
                string  res     = company.SetLikeUpdateOnPagePost(Linkedin_oauth, Updatekey, msg);
                return(new JavaScriptSerializer().Serialize(res));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return("Something Went Wrong");
            }
        }
 public void addLinkenCompanyPage(Domain.Myfashion.Domain.LinkedinCompanyPage linkedincompanypage)
 {
     //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(linkedincompanypage);
             transaction.Commit();
         } //End Transaction
     }     //End Session
 }
 public void updateLinkedinPage(Domain.Myfashion.Domain.LinkedinCompanyPage linkedinPage)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 session.CreateQuery("Update LinkedinCompanyPage set LinkedinPageName =:LinkedinPageName,EmailDomains =:EmailDomains,OAuthToken =:OAuthToken,OAuthSecret=:OAuthSecret,OAuthVerifier=:OAuthVerifier,Description=:Description,FoundedYear=:FoundedYear,EndYear =:EndYear,Locations=:Locations,Specialties=:Specialties,WebsiteUrl=:WebsiteUrl,Status=:Status,EmployeeCountRange=:EmployeeCountRange,Industries=:Industries,CompanyType=:CompanyType,LogoUrl=:LogoUrl,SquareLogoUrl=:SquareLogoUrl,BlogRssUrl=:BlogRssUrl,UniversalName=:UniversalName,NumFollowers=:NumFollowers where LinkedinPageId = :linkedinpageid and UserId = :UserId")
                 .SetParameter("LinkedinPageName", linkedinPage.LinkedinPageName)
                 .SetParameter("EmailDomains", linkedinPage.EmailDomains)
                 .SetParameter("OAuthToken", linkedinPage.OAuthToken)
                 .SetParameter("OAuthSecret", linkedinPage.OAuthSecret)
                 .SetParameter("OAuthVerifier", linkedinPage.OAuthVerifier)
                 .SetParameter("Description", linkedinPage.Description)
                 .SetParameter("FoundedYear", linkedinPage.FoundedYear)
                 .SetParameter("EndYear", linkedinPage.EndYear)
                 .SetParameter("Locations", linkedinPage.Locations)
                 .SetParameter("Specialties", linkedinPage.Specialties)
                 .SetParameter("WebsiteUrl", linkedinPage.WebsiteUrl)
                 .SetParameter("Status", linkedinPage.Status)
                 .SetParameter("EmployeeCountRange", linkedinPage.EmployeeCountRange)
                 .SetParameter("Industries", linkedinPage.Industries)
                 .SetParameter("CompanyType", linkedinPage.CompanyType)
                 .SetParameter("LogoUrl", linkedinPage.LogoUrl)
                 .SetParameter("SquareLogoUrl", linkedinPage.SquareLogoUrl)
                 .SetParameter("BlogRssUrl", linkedinPage.BlogRssUrl)
                 .SetParameter("UniversalName", linkedinPage.UniversalName)
                 .SetParameter("NumFollowers", linkedinPage.NumFollowers)
                 .SetParameter("linkedinpageid", linkedinPage.LinkedinPageId)
                 .SetParameter("UserId", linkedinPage.UserId)
                 .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         }
     }
 }
 public string GetLinkedinCompanyPageDetailsByUserIdAndPageId(string UserId, string LinkedinPageId)
 {
     Domain.Myfashion.Domain.LinkedinCompanyPage LinkedinCompanyPage = new Domain.Myfashion.Domain.LinkedinCompanyPage();
     try
     {
         Guid Userid = Guid.Parse(UserId);
         if (objLinkedCmpnyPgeRepo.checkLinkedinPageExists(LinkedinPageId, Userid))
         {
             LinkedinCompanyPage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(Userid, LinkedinPageId);
         }
         else
         {
             LinkedinCompanyPage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(LinkedinPageId);
         }
         return(new JavaScriptSerializer().Serialize(LinkedinCompanyPage));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return(new JavaScriptSerializer().Serialize("Please Try Again"));
     }
 }
 public string PsotCommentOnLinkedinCompanyPageUpdate(string UserId, string PageId, string Updatekey, string Comment)
 {
     try
     {
         Domain.Myfashion.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Myfashion.Domain.LinkedinCompanyPage();
         objlicompanypage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(PageId);
         oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
         Linkedin_oauth.Verifier    = objlicompanypage.OAuthVerifier;
         Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret;
         Linkedin_oauth.Token       = objlicompanypage.OAuthToken;
         Linkedin_oauth.Id          = objlicompanypage.LinkedinPageId;
         Linkedin_oauth.FirstName   = objlicompanypage.LinkedinPageName;
         Company company = new Company();
         string  res     = company.SetCommentOnPagePost(Linkedin_oauth, PageId, Updatekey, Comment);
         return(new JavaScriptSerializer().Serialize(res));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return("Something Went Wrong");
     }
 }
 public string GetLinkedinCompanyPageDetailsByUserIdAndPageId(string UserId, string LinkedinPageId)
 {
     Domain.Myfashion.Domain.LinkedinCompanyPage LinkedinCompanyPage=new Domain.Myfashion.Domain.LinkedinCompanyPage ();
     try
     {
         Guid Userid = Guid.Parse(UserId);
         if (objLinkedCmpnyPgeRepo.checkLinkedinPageExists(LinkedinPageId, Userid))
         {
             LinkedinCompanyPage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(Userid, LinkedinPageId);
         }
         else
         {
             LinkedinCompanyPage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(LinkedinPageId);
         }
         return new JavaScriptSerializer().Serialize(LinkedinCompanyPage);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return new JavaScriptSerializer().Serialize("Please Try Again");
     }
 }
        public string PutLikeOnLinkedinCompanyPageUpdate(string UserId, string PageId, string Updatekey, string IsLike)
        {
            try
            {
                string msg = string.Empty;

                int isLike = Convert.ToInt16(IsLike);

                if (isLike == 1)
                {
                    msg = "false";
                }
                else
                { msg = "true"; }

                Domain.Myfashion.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Myfashion.Domain.LinkedinCompanyPage();
                objlicompanypage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(PageId);
                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                Linkedin_oauth.Verifier = objlicompanypage.OAuthVerifier;
                Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret;
                Linkedin_oauth.Token = objlicompanypage.OAuthToken;
                Linkedin_oauth.Id = objlicompanypage.LinkedinPageId;
                Linkedin_oauth.FirstName = objlicompanypage.LinkedinPageName;
                Company company = new Company();
                string res = company.SetLikeUpdateOnPagePost(Linkedin_oauth, Updatekey, msg);
                return new JavaScriptSerializer().Serialize(res);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }

        }
        public string PsotCommentOnLinkedinCompanyPageUpdate(string UserId, string PageId, string Updatekey, string Comment)
        {
            try
            {
                Domain.Myfashion.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Myfashion.Domain.LinkedinCompanyPage();
                objlicompanypage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(PageId);
                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                Linkedin_oauth.Verifier = objlicompanypage.OAuthVerifier;
                Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret;
                Linkedin_oauth.Token = objlicompanypage.OAuthToken;
                Linkedin_oauth.Id = objlicompanypage.LinkedinPageId;
                Linkedin_oauth.FirstName = objlicompanypage.LinkedinPageName;
                Company company = new Company();
                string res = company.SetCommentOnPagePost(Linkedin_oauth, PageId, Updatekey, Comment);
                return new JavaScriptSerializer().Serialize(res);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }

        }
        public void GetPageProfile(dynamic data, oAuthLinkedIn _OAuth, string UserId, string CompanyPageId, string GroupId)
        {
            Domain.Myfashion.Domain.SocialProfile socioprofile = new Domain.Myfashion.Domain.SocialProfile();
            SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            Domain.Myfashion.Domain.LinkedinCompanyPage objLinkedincmpnypage = new Domain.Myfashion.Domain.LinkedinCompanyPage();
            LinkedinCompanyPageRepository objLinkedCmpnyPgeRepo = new LinkedinCompanyPageRepository();
            try
            {
                objLinkedincmpnypage.UserId = Guid.Parse(UserId);
                try
                {
                    objLinkedincmpnypage.LinkedinPageId = data.Pageid.ToString();
                }
                catch
                {
                }
                objLinkedincmpnypage.Id = Guid.NewGuid();
                try
                {
                    objLinkedincmpnypage.EmailDomains = data.EmailDomains.ToString();
                }
                catch { }
                objLinkedincmpnypage.LinkedinPageName = data.name.ToString();
                objLinkedincmpnypage.OAuthToken = _OAuth.Token;
                objLinkedincmpnypage.OAuthSecret = _OAuth.TokenSecret;
                objLinkedincmpnypage.OAuthVerifier = _OAuth.Verifier;
                try
                {
                    objLinkedincmpnypage.Description = data.description.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.FoundedYear = data.founded_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EndYear = data.end_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Locations = data.locations.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Specialties = data.Specialties.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.WebsiteUrl = data.website_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Status = data.status.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EmployeeCountRange = data.employee_count_range.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Industries = data.industries.ToString();
                }
                catch { }
                try
                {
                    string NuberOfFollower = data.num_followers.ToString();
                    objLinkedincmpnypage.NumFollowers = Convert.ToInt16(NuberOfFollower);
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.CompanyType = data.company_type.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.LogoUrl = data.logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.SquareLogoUrl = data.square_logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.BlogRssUrl = data.blog_rss_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.UniversalName = data.universal_name.ToString();
                }
                catch { }
                #region SocialProfiles
                socioprofile.UserId = Guid.Parse(UserId);
                socioprofile.ProfileType = "linkedincompanypage";
                socioprofile.ProfileId = data.Pageid.ToString(); ;
                socioprofile.ProfileStatus = 1;
                socioprofile.ProfileDate = DateTime.Now;
                socioprofile.Id = Guid.NewGuid();
                #endregion

                #region TeamMemberProfile
                Domain.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                objTeamMemberProfile = new Domain.Myfashion.Domain.TeamMemberProfile();
                objTeamMemberProfile.Id = Guid.NewGuid();
                objTeamMemberProfile.TeamId = objTeam.Id;
                objTeamMemberProfile.Status = 1;
                objTeamMemberProfile.ProfileType = "linkedincompanypage";
                objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                objTeamMemberProfile.ProfileId = socioprofile.ProfileId;
                #endregion
            }
            catch
            {
            }
            try
            {
                if (!objSocialProfilesRepository.checkUserProfileExist(socioprofile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(socioprofile);
                }
                if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedincmpnypage.LinkedinPageId))
                {
                    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                }
                if (!objLinkedCmpnyPgeRepo.checkLinkedinPageExists(CompanyPageId, Guid.Parse(UserId)))
                {
                    objLinkedCmpnyPgeRepo.addLinkenCompanyPage(objLinkedincmpnypage);
                }
                else
                {
                    objLinkedincmpnypage.LinkedinPageId = CompanyPageId;
                    objLinkedCmpnyPgeRepo.updateLinkedinPage(objLinkedincmpnypage);
                }
            }
            catch
            {

            }

        }
        public void GetPageProfile(dynamic data, oAuthLinkedIn _OAuth, string UserId, string CompanyPageId, string GroupId)
        {
            Domain.Myfashion.Domain.SocialProfile socioprofile = new Domain.Myfashion.Domain.SocialProfile();
            SocialProfilesRepository socioprofilerepo          = new SocialProfilesRepository();

            Domain.Myfashion.Domain.LinkedinCompanyPage objLinkedincmpnypage = new Domain.Myfashion.Domain.LinkedinCompanyPage();
            LinkedinCompanyPageRepository objLinkedCmpnyPgeRepo = new LinkedinCompanyPageRepository();

            try
            {
                objLinkedincmpnypage.UserId = Guid.Parse(UserId);
                try
                {
                    objLinkedincmpnypage.LinkedinPageId = data.Pageid.ToString();
                }
                catch
                {
                }
                objLinkedincmpnypage.Id = Guid.NewGuid();
                try
                {
                    objLinkedincmpnypage.EmailDomains = data.EmailDomains.ToString();
                }
                catch { }
                objLinkedincmpnypage.LinkedinPageName = data.name.ToString();
                objLinkedincmpnypage.OAuthToken       = _OAuth.Token;
                objLinkedincmpnypage.OAuthSecret      = _OAuth.TokenSecret;
                objLinkedincmpnypage.OAuthVerifier    = _OAuth.Verifier;
                try
                {
                    objLinkedincmpnypage.Description = data.description.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.FoundedYear = data.founded_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EndYear = data.end_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Locations = data.locations.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Specialties = data.Specialties.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.WebsiteUrl = data.website_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Status = data.status.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EmployeeCountRange = data.employee_count_range.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Industries = data.industries.ToString();
                }
                catch { }
                try
                {
                    string NuberOfFollower = data.num_followers.ToString();
                    objLinkedincmpnypage.NumFollowers = Convert.ToInt16(NuberOfFollower);
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.CompanyType = data.company_type.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.LogoUrl = data.logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.SquareLogoUrl = data.square_logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.BlogRssUrl = data.blog_rss_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.UniversalName = data.universal_name.ToString();
                }
                catch { }
                #region SocialProfiles
                socioprofile.UserId        = Guid.Parse(UserId);
                socioprofile.ProfileType   = "linkedincompanypage";
                socioprofile.ProfileId     = data.Pageid.ToString();;
                socioprofile.ProfileStatus = 1;
                socioprofile.ProfileDate   = DateTime.Now;
                socioprofile.Id            = Guid.NewGuid();
                #endregion

                #region TeamMemberProfile
                Domain.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                objTeamMemberProfile                  = new Domain.Myfashion.Domain.TeamMemberProfile();
                objTeamMemberProfile.Id               = Guid.NewGuid();
                objTeamMemberProfile.TeamId           = objTeam.Id;
                objTeamMemberProfile.Status           = 1;
                objTeamMemberProfile.ProfileType      = "linkedincompanypage";
                objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                objTeamMemberProfile.ProfileId        = socioprofile.ProfileId;
                #endregion
            }
            catch
            {
            }
            try
            {
                if (!objSocialProfilesRepository.checkUserProfileExist(socioprofile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(socioprofile);
                }
                if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedincmpnypage.LinkedinPageId))
                {
                    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                }
                if (!objLinkedCmpnyPgeRepo.checkLinkedinPageExists(CompanyPageId, Guid.Parse(UserId)))
                {
                    objLinkedCmpnyPgeRepo.addLinkenCompanyPage(objLinkedincmpnypage);
                }
                else
                {
                    objLinkedincmpnypage.LinkedinPageId = CompanyPageId;
                    objLinkedCmpnyPgeRepo.updateLinkedinPage(objLinkedincmpnypage);
                }
            }
            catch
            {
            }
        }
        public Domain.Myfashion.Domain.LinkedinCompanyPage getCompanyPageInformation(string liPageid)
        {
            //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())
                {
                    try
                    {
                        //Proceed action, to get details of account.
                        List<Domain.Myfashion.Domain.LinkedinCompanyPage> objlst = session.CreateQuery("from LinkedinCompanyPage where LinkedinPageId = :linkedinpageid ")
                        .SetParameter("linkedinpageid", liPageid)
                        .List<Domain.Myfashion.Domain.LinkedinCompanyPage>().ToList<Domain.Myfashion.Domain.LinkedinCompanyPage>();
                        Domain.Myfashion.Domain.LinkedinCompanyPage result = new Domain.Myfashion.Domain.LinkedinCompanyPage();
                        if (objlst.Count > 0)
                        {
                            result = objlst[0];
                        }
                        return result;

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return null;
                    }
                }//End Transaction
            }//End Session
        }