/// <updateLinkedinUser> /// Update Linkedin User account details. /// </summary> /// <param name="liaccount">Set Values in a LinkedInAccount Class Property and Pass the Object of LinkedInAccount Class (SocioBoard.Domain.LinkedInAccount).</param> public void updateLinkedinUser(Domain.Myfashion.Domain.LinkedInAccount liaccount) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { session.CreateQuery("Update LinkedInAccount set LinkedinUserName =:LinkedinUserName,OAuthToken =:OAuthToken,OAuthSecret=:OAuthSecret,OAuthVerifier=:OAuthVerifier,EmailId=:EmailId,Connections=:Connections,ProfileUrl =:profileurl,ProfileImageUrl=:profilepicurl where LinkedinUserId = :LinkedinUserId and UserId = :UserId") .SetParameter("LinkedinUserName", liaccount.LinkedinUserName) .SetParameter("OAuthToken", liaccount.OAuthToken) .SetParameter("OAuthSecret", liaccount.OAuthSecret) .SetParameter("OAuthVerifier", liaccount.OAuthVerifier) .SetParameter("EmailId", liaccount.EmailId) .SetParameter("LinkedinUserId", liaccount.LinkedinUserId) .SetParameter("UserId", liaccount.UserId) .SetParameter("profileurl", liaccount.ProfileUrl) .SetParameter("profilepicurl", liaccount.ProfileImageUrl) .SetParameter("Connections", liaccount.Connections) .ExecuteUpdate(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); // return 0; } } } }
/// <getUserInformation> /// Get user linkedin account information /// </summary> /// <param name="userid">User id (Guid)</param> /// <param name="liuserid">Linkedin account Id (String)</param> /// <returns>Return object of LinkedInAccount Class with value of each member.(Domain.LinkedInAccount)</returns> public Domain.Myfashion.Domain.LinkedInAccount getUserInformation(Guid userid, string liuserid) { //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 LinkedInAccount where LinkedinUserId = :LinkedinUserId And UserId=:UserId"); query.SetParameter("UserId", userid); query.SetParameter("LinkedinUserId", liuserid); Domain.Myfashion.Domain.LinkedInAccount result = query.UniqueResult <Domain.Myfashion.Domain.LinkedInAccount>(); return(result); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } } //End Transaction } //End Session }
public Domain.Myfashion.Domain.LinkedInAccount getUserInformation(string liuserid) { //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.LinkedInAccount> objlst = session.CreateQuery("from LinkedInAccount where LinkedinUserId = :LinkedinUserId ") .SetParameter("LinkedinUserId", liuserid) .List <Domain.Myfashion.Domain.LinkedInAccount>().ToList <Domain.Myfashion.Domain.LinkedInAccount>(); Domain.Myfashion.Domain.LinkedInAccount result = new Domain.Myfashion.Domain.LinkedInAccount(); if (objlst.Count > 0) { result = objlst[0]; } return(result); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } } //End Transaction } //End Session }
/// <getLinkedinAccountDetailsById> /// Get linkedin account details by id /// </summary> /// <param name="liuserid"></param> /// <returns>Return object of LinkedInAccount Class with value of each member.(Domain.LinkedInAccount)</returns> public Domain.Myfashion.Domain.LinkedInAccount getLinkedinAccountDetailsById(string liuserid) { //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 account details. NHibernate.IQuery query = session.CreateQuery("from LinkedInAccount where LinkedinUserId = :userid"); query.SetParameter("userid", liuserid); Domain.Myfashion.Domain.LinkedInAccount result = new Domain.Myfashion.Domain.LinkedInAccount(); foreach (Domain.Myfashion.Domain.LinkedInAccount item in query.Enumerable <Domain.Myfashion.Domain.LinkedInAccount>()) { result = item; break; } return(result); } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } } //End Transaction } //End Session }
public string UpdateLinkedinAccountByAdmin(string ObjLinkedin) { Domain.Myfashion.Domain.LinkedInAccount objLinkedinAccount = (Domain.Myfashion.Domain.LinkedInAccount)(new JavaScriptSerializer().Deserialize(ObjLinkedin, typeof(Domain.Myfashion.Domain.LinkedInAccount))); try { objLinkedInAccountRepository.updateLinkedinUser(objLinkedinAccount); return(new JavaScriptSerializer().Serialize("Update Successfully")); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Something went Wrong")); } }
/// <addLinkedinUser> /// Add Linked in User /// </summary> /// <param name="linkedInAccount">Set Values in a LinkedInAccount Class Property and Pass the Object of LinkedInAccount Class (SocioBoard.Domain.LinkedInAccount).</param> public void addLinkedinUser(Domain.Myfashion.Domain.LinkedInAccount linkedInAccount) { //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(linkedInAccount); transaction.Commit(); } //End Transaction } //End Session }
public string UserInformation(string UserId, string LinkedinId) { try { Guid Userid = Guid.Parse(UserId); Domain.Myfashion.Domain.LinkedInAccount LinkedAccount = objlinkedinaccrepo.getUserInformation(Userid, LinkedinId); return(new JavaScriptSerializer().Serialize(LinkedAccount)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Please Try Again")); } }
public string LinkedinProfileDetails(string Userid, string ProfileId) { Domain.Myfashion.Domain.LinkedInAccount objLinkedinAccount = new Domain.Myfashion.Domain.LinkedInAccount(); LinkedInAccountRepository _objLinkedInAccountRepository = new LinkedInAccountRepository(); if (_objLinkedInAccountRepository.checkLinkedinUserExists(ProfileId, Guid.Parse(Userid))) { objLinkedinAccount = _objLinkedInAccountRepository.getUserInformation(Guid.Parse(Userid), ProfileId); } else { objLinkedinAccount = _objLinkedInAccountRepository.getUserInformation(ProfileId); } return(new JavaScriptSerializer().Serialize(objLinkedinAccount)); }
public string GetLinkedinAccountDetailsById(string UserId, string LinkedinId) { Domain.Myfashion.Domain.LinkedInAccount LinkedAccount=new LinkedInAccount (); try { Guid Userid = Guid.Parse(UserId); if(objlinkedinaccrepo.checkLinkedinUserExists(LinkedinId,Userid)) { LinkedAccount = objlinkedinaccrepo.getUserInformation(Userid, LinkedinId); } else { LinkedAccount=objlinkedinaccrepo.getUserInformation(LinkedinId); } return new JavaScriptSerializer().Serialize(LinkedAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return new JavaScriptSerializer().Serialize("Please Try Again"); } }
public string LinkedinProfileDetails(string Userid, string ProfileId) { Domain.Myfashion.Domain.LinkedInAccount objLinkedinAccount = new Domain.Myfashion.Domain.LinkedInAccount(); LinkedInAccountRepository _objLinkedInAccountRepository = new LinkedInAccountRepository(); if (_objLinkedInAccountRepository.checkLinkedinUserExists(ProfileId, Guid.Parse(Userid))) { objLinkedinAccount = _objLinkedInAccountRepository.getUserInformation(Guid.Parse(Userid), ProfileId); } else { objLinkedinAccount = _objLinkedInAccountRepository.getUserInformation(ProfileId); } return new JavaScriptSerializer().Serialize(objLinkedinAccount); }
public void GetLinkedInUserProfile(dynamic data, oAuthLinkedIn _oauth, Guid user, string LinkedinUserId) { LinkedInAccount objLinkedInAccount = new LinkedInAccount(); LinkedInAccountRepository objLiRepo = new LinkedInAccountRepository(); try { objLinkedInAccount.UserId = user; objLinkedInAccount.LinkedinUserId = data.id.ToString(); try { objLinkedInAccount.EmailId = data.email.ToString(); } catch { } objLinkedInAccount.LinkedinUserName = data.first_name.ToString() + data.last_name.ToString(); objLinkedInAccount.OAuthToken = _oauth.Token; objLinkedInAccount.OAuthSecret = _oauth.TokenSecret; objLinkedInAccount.OAuthVerifier = _oauth.Verifier; try { objLinkedInAccount.ProfileImageUrl = data.picture_url.ToString(); } catch { } try { objLinkedInAccount.ProfileUrl = data.profile_url.ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } objLinkedInAccount.Connections = data.connections; objLinkedInAccount.IsActive = true; objLiRepo.updateLinkedinUser(objLinkedInAccount); } catch { } }
public string AddLinkedinAccount(string oauth_token, string oauth_verifier, string reuqestTokenSecret, string consumerKey, string consumerSecret, string UserId, string GroupId) { try { logger.Error("AddLinkedinAccount()"); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; string ret = string.Empty; LinkedInProfile objProfile = new LinkedInProfile(); LinkedInProfile.UserProfile objUserProfile = new LinkedInProfile.UserProfile(); objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); oAuthLinkedIn _oauth = new oAuthLinkedIn(); objLinkedInAccount = new LinkedInAccount(); #region Get linkedin Profile data from Api try { _oauth.ConsumerKey = consumerKey; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.ConsumerSecret = consumerSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.Token = oauth_token; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.TokenSecret = reuqestTokenSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.Verifier = oauth_verifier; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.AccessTokenGet(oauth_token); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { objUserProfile = objProfile.GetUserProfile(_oauth); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } #endregion dynamic data = objUserProfile; try { #region LinkedInAccount objLinkedInAccount.UserId = Guid.Parse(UserId); objLinkedInAccount.LinkedinUserId = data.id.ToString(); try { objLinkedInAccount.EmailId = data.email.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } objLinkedInAccount.LinkedinUserName = data.first_name.ToString() + data.last_name.ToString(); objLinkedInAccount.OAuthToken = _oauth.Token; objLinkedInAccount.OAuthSecret = _oauth.TokenSecret; objLinkedInAccount.OAuthVerifier = _oauth.Verifier; try { objLinkedInAccount.ProfileImageUrl = data.picture_url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objLinkedInAccount.ProfileUrl = data.profile_url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } #endregion #region SocialProfiles try { objLinkedInAccount.Connections = data.connections; objLinkedInAccount.IsActive = true; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileType = "linkedin"; objSocialProfile.ProfileId = data.id.ToString(); objSocialProfile.ProfileStatus = 1; objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.Id = Guid.NewGuid(); } catch (Exception ex) { logger.Error(ex.Message); } #endregion SocialProfiles #region Add TeamMemberProfile try { 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 = "linkedin"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objLinkedInAccount.LinkedinUserId; objTeamMemberProfile.ProfileName = objLinkedInAccount.LinkedinUserName; objTeamMemberProfile.ProfilePicUrl = objLinkedInAccount.ProfileImageUrl; } catch (Exception ex) { logger.Error(ex.Message); } #endregion } catch (Exception ex) { logger.Error(ex.StackTrace); } try { if (!objLinkedInAccountRepository.checkLinkedinUserExists(objLinkedInAccount.LinkedinUserId, Guid.Parse(UserId))) { objLinkedInAccountRepository.addLinkedinUser(objLinkedInAccount); ret = "LinkedIn Account Added Successfully"; } else { ret = "LinkedIn Account Already Exist"; } if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedInAccount.LinkedinUserId)) { objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } #region Add LinkedIn Feeds LinkedInNetwork objln = new LinkedInNetwork(); List<LinkedInNetwork.Network_Updates> userUPdate = objln.GetNetworkUpdates(_oauth, 20); foreach (var item in userUPdate) { try { objLinkedInFeed = new Domain.Myfashion.Domain.LinkedInFeed(); objLinkedInFeed.Feeds = item.Message; objLinkedInFeed.FromId = item.PersonId; objLinkedInFeed.FromName = item.PersonFirstName + " " + item.PersonLastName; objLinkedInFeed.FeedsDate = Convert.ToDateTime(item.DateTime); objLinkedInFeed.EntryDate = DateTime.Now; objLinkedInFeed.ProfileId = objLinkedInAccount.LinkedinUserId; objLinkedInFeed.Type = item.UpdateType; objLinkedInFeed.UserId = Guid.Parse(UserId); objLinkedInFeed.FromPicUrl = item.PictureUrl; objLinkedInFeed.ImageUrl = item.ImageUrl; objLinkedInFeed.FromUrl = item.url; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objLinkedInFeedRepository.checkLinkedInFeedExists(objLinkedInFeed.FeedId, Guid.Parse(UserId))) { objLinkedInFeedRepository.addLinkedInFeed(objLinkedInFeed); } } #endregion #region Add LinkedIn UserUpdates GlobusLinkedinLib.App.Core.LinkedInUser l = new GlobusLinkedinLib.App.Core.LinkedInUser(); List<Domain.Myfashion.Domain.LinkedIn_Update_Messages> lst_Messages = l.GetUserUpdateNew(_oauth, objLinkedInAccount.LinkedinUserId, 10); foreach (var item_Messages in lst_Messages) { try { objLinkedInMessage = new Domain.Myfashion.Domain.LinkedInMessage(); objLinkedInMessage.Id = Guid.NewGuid(); objLinkedInMessage.Message = item_Messages.Message; objLinkedInMessage.ProfileId = item_Messages.ProfileId; objLinkedInMessage.ProfileName = item_Messages.ProfileName; objLinkedInMessage.CreatedDate = Convert.ToDateTime(item_Messages.CreatedDate); objLinkedInMessage.EntryDate = DateTime.Now; objLinkedInMessage.Type = item_Messages.Type; objLinkedInMessage.UserId = Guid.Parse(UserId); objLinkedInMessage.ImageUrl = item_Messages.ImageUrl; objLinkedInMessage.FeedId = item_Messages.FeedId; objLinkedInMessage.ProfileUrl = item_Messages.ProfileUrl; objLinkedInMessage.Comments = item_Messages.Comments; objLinkedInMessage.Likes = item_Messages.Likes; objLinkedInMessage.ProfileImageUrl = item_Messages.ProfileImageUrl; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objLinkedInMessageRepository.checkLinkedInMessageExists(objLinkedInAccount.LinkedinUserId, objLinkedInMessage.FeedId, Guid.Parse(UserId))) { objLinkedInMessageRepository.addLinkedInMessage(objLinkedInMessage); } } #endregion } catch (Exception ex) { logger.Error(ex.StackTrace); } return ""; } catch (Exception ex) { logger.Error(ex.StackTrace); return ""; } }
public string AddLinkedinAccount(string oauth_token, string oauth_verifier, string reuqestTokenSecret, string consumerKey, string consumerSecret, string UserId, string GroupId) { try { logger.Error("AddLinkedinAccount()"); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; string ret = string.Empty; LinkedInProfile objProfile = new LinkedInProfile(); LinkedInProfile.UserProfile objUserProfile = new LinkedInProfile.UserProfile(); objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); oAuthLinkedIn _oauth = new oAuthLinkedIn(); objLinkedInAccount = new LinkedInAccount(); #region Get linkedin Profile data from Api try { _oauth.ConsumerKey = consumerKey; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.ConsumerSecret = consumerSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.Token = oauth_token; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.TokenSecret = reuqestTokenSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.Verifier = oauth_verifier; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.AccessTokenGet(oauth_token); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { objUserProfile = objProfile.GetUserProfile(_oauth); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } #endregion dynamic data = objUserProfile; try { #region LinkedInAccount objLinkedInAccount.UserId = Guid.Parse(UserId); objLinkedInAccount.LinkedinUserId = data.id.ToString(); try { objLinkedInAccount.EmailId = data.email.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } objLinkedInAccount.LinkedinUserName = data.first_name.ToString() + data.last_name.ToString(); objLinkedInAccount.OAuthToken = _oauth.Token; objLinkedInAccount.OAuthSecret = _oauth.TokenSecret; objLinkedInAccount.OAuthVerifier = _oauth.Verifier; try { objLinkedInAccount.ProfileImageUrl = data.picture_url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objLinkedInAccount.ProfileUrl = data.profile_url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } #endregion #region SocialProfiles try { objLinkedInAccount.Connections = data.connections; objLinkedInAccount.IsActive = true; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileType = "linkedin"; objSocialProfile.ProfileId = data.id.ToString(); objSocialProfile.ProfileStatus = 1; objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.Id = Guid.NewGuid(); } catch (Exception ex) { logger.Error(ex.Message); } #endregion SocialProfiles #region Add TeamMemberProfile try { 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 = "linkedin"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objLinkedInAccount.LinkedinUserId; objTeamMemberProfile.ProfileName = objLinkedInAccount.LinkedinUserName; objTeamMemberProfile.ProfilePicUrl = objLinkedInAccount.ProfileImageUrl; } catch (Exception ex) { logger.Error(ex.Message); } #endregion } catch (Exception ex) { logger.Error(ex.StackTrace); } try { if (!objLinkedInAccountRepository.checkLinkedinUserExists(objLinkedInAccount.LinkedinUserId, Guid.Parse(UserId))) { objLinkedInAccountRepository.addLinkedinUser(objLinkedInAccount); ret = "LinkedIn Account Added Successfully"; } else { ret = "LinkedIn Account Already Exist"; } if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedInAccount.LinkedinUserId)) { objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } #region Add LinkedIn Feeds LinkedInNetwork objln = new LinkedInNetwork(); List <LinkedInNetwork.Network_Updates> userUPdate = objln.GetNetworkUpdates(_oauth, 20); foreach (var item in userUPdate) { try { objLinkedInFeed = new Domain.Myfashion.Domain.LinkedInFeed(); objLinkedInFeed.Feeds = item.Message; objLinkedInFeed.FromId = item.PersonId; objLinkedInFeed.FromName = item.PersonFirstName + " " + item.PersonLastName; objLinkedInFeed.FeedsDate = Convert.ToDateTime(item.DateTime); objLinkedInFeed.EntryDate = DateTime.Now; objLinkedInFeed.ProfileId = objLinkedInAccount.LinkedinUserId; objLinkedInFeed.Type = item.UpdateType; objLinkedInFeed.UserId = Guid.Parse(UserId); objLinkedInFeed.FromPicUrl = item.PictureUrl; objLinkedInFeed.ImageUrl = item.ImageUrl; objLinkedInFeed.FromUrl = item.url; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objLinkedInFeedRepository.checkLinkedInFeedExists(objLinkedInFeed.FeedId, Guid.Parse(UserId))) { objLinkedInFeedRepository.addLinkedInFeed(objLinkedInFeed); } } #endregion #region Add LinkedIn UserUpdates GlobusLinkedinLib.App.Core.LinkedInUser l = new GlobusLinkedinLib.App.Core.LinkedInUser(); List <Domain.Myfashion.Domain.LinkedIn_Update_Messages> lst_Messages = l.GetUserUpdateNew(_oauth, objLinkedInAccount.LinkedinUserId, 10); foreach (var item_Messages in lst_Messages) { try { objLinkedInMessage = new Domain.Myfashion.Domain.LinkedInMessage(); objLinkedInMessage.Id = Guid.NewGuid(); objLinkedInMessage.Message = item_Messages.Message; objLinkedInMessage.ProfileId = item_Messages.ProfileId; objLinkedInMessage.ProfileName = item_Messages.ProfileName; objLinkedInMessage.CreatedDate = Convert.ToDateTime(item_Messages.CreatedDate); objLinkedInMessage.EntryDate = DateTime.Now; objLinkedInMessage.Type = item_Messages.Type; objLinkedInMessage.UserId = Guid.Parse(UserId); objLinkedInMessage.ImageUrl = item_Messages.ImageUrl; objLinkedInMessage.FeedId = item_Messages.FeedId; objLinkedInMessage.ProfileUrl = item_Messages.ProfileUrl; objLinkedInMessage.Comments = item_Messages.Comments; objLinkedInMessage.Likes = item_Messages.Likes; objLinkedInMessage.ProfileImageUrl = item_Messages.ProfileImageUrl; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objLinkedInMessageRepository.checkLinkedInMessageExists(objLinkedInAccount.LinkedinUserId, objLinkedInMessage.FeedId, Guid.Parse(UserId))) { objLinkedInMessageRepository.addLinkedInMessage(objLinkedInMessage); } } #endregion } catch (Exception ex) { logger.Error(ex.StackTrace); } return(""); } catch (Exception ex) { logger.Error(ex.StackTrace); return(""); } }
public Domain.Myfashion.Domain.LinkedInAccount getUserInformation(string liuserid) { //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.LinkedInAccount> objlst = session.CreateQuery("from LinkedInAccount where LinkedinUserId = :LinkedinUserId ") .SetParameter("LinkedinUserId", liuserid) .List<Domain.Myfashion.Domain.LinkedInAccount>().ToList<Domain.Myfashion.Domain.LinkedInAccount>(); Domain.Myfashion.Domain.LinkedInAccount result = new Domain.Myfashion.Domain.LinkedInAccount(); if (objlst.Count > 0) { result = objlst[0]; } return result; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return null; } }//End Transaction }//End Session }
/// <getLinkedinAccountDetailsById> /// Get linkedin account details by id /// </summary> /// <param name="liuserid"></param> /// <returns>Return object of LinkedInAccount Class with value of each member.(Domain.LinkedInAccount)</returns> public Domain.Myfashion.Domain.LinkedInAccount getLinkedinAccountDetailsById(string liuserid) { //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 account details. NHibernate.IQuery query = session.CreateQuery("from LinkedInAccount where LinkedinUserId = :userid"); query.SetParameter("userid", liuserid); Domain.Myfashion.Domain.LinkedInAccount result = new Domain.Myfashion.Domain.LinkedInAccount(); foreach (Domain.Myfashion.Domain.LinkedInAccount item in query.Enumerable<Domain.Myfashion.Domain.LinkedInAccount>()) { result = item; break; } return result; } catch (Exception ex) { Console.WriteLine(ex.Message); return null; } }//End Transaction }//End Session }