public string ProfilesConnected(string UserId) { try { Guid userid = Guid.Parse(UserId); SocialProfilesRepository socialRepo = new SocialProfilesRepository(); List<SocialProfile> lstsocioprofile = socialRepo.getAllSocialProfilesOfUser(userid); List<profileConnected> lstProfile = new List<profileConnected>(); foreach (SocialProfile sp in lstsocioprofile) { profileConnected pc = new profileConnected(); pc.Id = sp.Id; pc.ProfileDate = sp.ProfileDate; pc.ProfileId = sp.ProfileId; pc.ProfileStatus = sp.ProfileStatus; pc.ProfileType = sp.ProfileType; pc.UserId = sp.UserId; if (sp.ProfileType == "facebook") { try { FacebookAccountRepository objFbAccRepo = new FacebookAccountRepository(); FacebookAccount objFbAcc = objFbAccRepo.getUserDetails(sp.ProfileId); pc.ProfileName = objFbAcc.FbUserName; pc.ProfileImgUrl = "http://graph.facebook.com/" + sp.ProfileId + "/picture?type=small"; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "twitter") { try { TwitterAccountRepository objTwtAccRepo = new TwitterAccountRepository(); TwitterAccount objTwtAcc = objTwtAccRepo.getUserInfo(sp.ProfileId); pc.ProfileName = objTwtAcc.TwitterScreenName; pc.ProfileImgUrl = objTwtAcc.ProfileImageUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "instagram") { try { InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository(); InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountById(sp.ProfileId); pc.ProfileName = objInsAcc.InsUserName; pc.ProfileImgUrl = objInsAcc.ProfileUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "linkedin") { try { LinkedInAccountRepository objLiAccRepo = new LinkedInAccountRepository(); LinkedInAccount objLiAcc = objLiAccRepo.getLinkedinAccountDetailsById(sp.ProfileId); pc.ProfileName = objLiAcc.LinkedinUserName; pc.ProfileImgUrl = objLiAcc.ProfileImageUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "googleplus") { try { GooglePlusAccountRepository objGpAccRepo = new GooglePlusAccountRepository(); GooglePlusAccount objGpAcc = objGpAccRepo.getUserDetails(sp.ProfileId); pc.ProfileName = objGpAcc.GpUserName; pc.ProfileImgUrl = objGpAcc.GpProfileImage; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } lstProfile.Add(pc); } return new JavaScriptSerializer().Serialize(lstProfile); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return new JavaScriptSerializer().Serialize("Please Try Again"); } }
public string ProfilesConnected(string UserId) { try { Guid userid = Guid.Parse(UserId); SocialProfilesRepository socialRepo = new SocialProfilesRepository(); List <SocialProfile> lstsocioprofile = socialRepo.getAllSocialProfilesOfUser(userid); List <profileConnected> lstProfile = new List <profileConnected>(); foreach (SocialProfile sp in lstsocioprofile) { profileConnected pc = new profileConnected(); pc.Id = sp.Id; pc.ProfileDate = sp.ProfileDate; pc.ProfileId = sp.ProfileId; pc.ProfileStatus = sp.ProfileStatus; pc.ProfileType = sp.ProfileType; pc.UserId = sp.UserId; if (sp.ProfileType == "facebook") { try { FacebookAccountRepository objFbAccRepo = new FacebookAccountRepository(); FacebookAccount objFbAcc = objFbAccRepo.getUserDetails(sp.ProfileId); pc.ProfileName = objFbAcc.FbUserName; pc.ProfileImgUrl = "http://graph.facebook.com/" + sp.ProfileId + "/picture?type=small"; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "twitter") { try { TwitterAccountRepository objTwtAccRepo = new TwitterAccountRepository(); TwitterAccount objTwtAcc = objTwtAccRepo.getUserInfo(sp.ProfileId); pc.ProfileName = objTwtAcc.TwitterScreenName; pc.ProfileImgUrl = objTwtAcc.ProfileImageUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "instagram") { try { InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository(); InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountById(sp.ProfileId); pc.ProfileName = objInsAcc.InsUserName; pc.ProfileImgUrl = objInsAcc.ProfileUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "linkedin") { try { LinkedInAccountRepository objLiAccRepo = new LinkedInAccountRepository(); LinkedInAccount objLiAcc = objLiAccRepo.getLinkedinAccountDetailsById(sp.ProfileId); pc.ProfileName = objLiAcc.LinkedinUserName; pc.ProfileImgUrl = objLiAcc.ProfileImageUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "googleplus") { try { GooglePlusAccountRepository objGpAccRepo = new GooglePlusAccountRepository(); GooglePlusAccount objGpAcc = objGpAccRepo.getUserDetails(sp.ProfileId); pc.ProfileName = objGpAcc.GpUserName; pc.ProfileImgUrl = objGpAcc.GpProfileImage; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } lstProfile.Add(pc); } return(new JavaScriptSerializer().Serialize(lstProfile)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Please Try Again")); } }