/// <summary> /// Compares 2 userprofile. /// </summary> /// <param name="userProfile"></param> /// <param name="compUserProfile"></param> /// <param name="objectsToCompare"> optional (if not given, all objects will be taken into account)</param> /// <param name="networks"> optional (if not given, all networks will be added to the resulting usercomparison)</param> /// <returns></returns> internal static UserComparison CompareUserProfiles(ProfileData userProfile, ProfileData compUserProfile, IEnumerable<ProfileDataObjects> objectsToCompare = null, IEnumerable<Network> networks = null) { UserComparison userComparison = new UserComparison(); if (userProfile == null) userProfile = new ProfileData(); if (compUserProfile == null) compUserProfile = new ProfileData(); if(objectsToCompare == null) objectsToCompare = ProfileData.GetAllProfileDataObjects(); if (networks == null) networks = Network.GetAllNetworks(); userComparison.Networks = networks.ToList(); if (objectsToCompare.Contains(ProfileDataObjects.EDUCATION)) CompareEducation(ref userComparison, userProfile, compUserProfile); if(objectsToCompare.Contains(ProfileDataObjects.WORK)) CompareWork(ref userComparison, userProfile, compUserProfile); if (objectsToCompare.Contains(ProfileDataObjects.TEAM)) CompareInterests(ref userComparison, userProfile, compUserProfile, InterestType.TEAM); if (objectsToCompare.Contains(ProfileDataObjects.ATHLETE)) CompareInterests(ref userComparison, userProfile, compUserProfile, InterestType.ATHLETE); return userComparison; }
private static void CompareWork(ref UserComparison userComparison, ProfileData userProfile, ProfileData compUserProfile) { IEnumerable<Work> onlyProfile1WorkHistory = userProfile.WorkHistory.Except(compUserProfile.WorkHistory); IEnumerable<Work> onlyProfile2WorkHistory = compUserProfile.WorkHistory.Except(userProfile.WorkHistory); IEnumerable<Work> bothProfileWorkHistory = userProfile.WorkHistory.Except(onlyProfile1WorkHistory); userComparison.EqualProfileData.WorkHistory = bothProfileWorkHistory.ToList(); userComparison.OnlyUserProfileData.WorkHistory = onlyProfile1WorkHistory.ToList(); userComparison.OnlyCompUserProfileData.WorkHistory = onlyProfile2WorkHistory.ToList(); }
private static void CompareEducation(ref UserComparison userComparison, ProfileData userProfile, ProfileData compUserProfile) { //IEnumerable<Education> onlyProfile1Educations = userProfile.EducationList.Except(compUserProfile.EducationList); //IEnumerable<Education> onlyProfile2Educations = compUserProfile.EducationList.Except(userProfile.EducationList); IEnumerable<Education> bothProfileEducations = userProfile.EducationList.Intersect(compUserProfile.EducationList); userComparison.EqualProfileData.EducationList = bothProfileEducations.ToList(); //userComparison.OnlyUserProfileData.EducationList = onlyProfile1Educations.ToList(); //userComparison.OnlyCompUserProfileData.EducationList = onlyProfile2Educations.ToList(); }
private static void CompareInterests(ref UserComparison userComparison, ProfileData userProfile, ProfileData compUserProfile, InterestType typeToCompare) { IEnumerable<Interest> onlyProfile1Interests = userProfile.Interests.Where(x => x.type == typeToCompare).Except(compUserProfile.Interests); IEnumerable<Interest> onlyProfile2Interests = compUserProfile.Interests.Where(x => x.type == typeToCompare).Except(userProfile.Interests); IEnumerable<Interest> bothProfileInterests = userProfile.Interests.Where(x => x.type == typeToCompare).Except(onlyProfile1Interests); //For the interests Add instead of = (other interest types could have been already added) userComparison.EqualProfileData.Interests.AddRange(bothProfileInterests.ToList()); userComparison.OnlyUserProfileData.Interests.AddRange(onlyProfile1Interests.ToList()); //userComparison.OnlyCompUserProfileData.Interests.RemoveAll(x => x.Type == typeToCompare); userComparison.OnlyCompUserProfileData.Interests.AddRange(onlyProfile2Interests.ToList()); }
internal static ProfileData ParseFBData(JObject fbJson) { ProfileData profileData = new ProfileData() { ProfilePicUrl = (string)fbJson[FBFields.PICTURE.ToString().ToLower()]["data"]["url"], FirstName = (string)fbJson[FBFields.FIRST_NAME.ToString().ToLower()], LastName = (string)fbJson[FBFields.LAST_NAME.ToString().ToLower()], Bio = (string)fbJson[FBFields.BIO.ToString().ToLower()], About = (string)fbJson[FBFields.ABOUT.ToString().ToLower()], Gender = (string)fbJson[FBFields.GENDER.ToString().ToLower()], ProfileLink = (string)fbJson[FBFields.LINK.ToString().ToLower()] }; try { JArray jEducations = (JArray)fbJson[FBFields.EDUCATION.ToString().ToLower()]; foreach (JObject jEducation in jEducations) { profileData.EducationList.Add(new Education() { name = (string)jEducation["school"]["name"], type = (string)jEducation["type"], yearTo = ((jEducation["year"] != null) ? (int?)jEducation["year"]["name"] : null) }); } } catch(Exception e) { } try { JArray jWorkHistory = (JArray)fbJson[FBFields.WORK.ToString().ToLower()]; foreach (JObject jWork in jWorkHistory) { profileData.WorkHistory.Add(new Work() { name = (string)jWork["employer"]["name"], type = "Company", dateFrom = (!JsonUtil.IsNullOrEmpty(jWork.SelectToken("start_date"))) ? (string)jWork["start_date"] : null, dateTo = (!JsonUtil.IsNullOrEmpty(jWork.SelectToken("end_date"))) ? (string)jWork["end_date"] : null, city = (!JsonUtil.IsNullOrEmpty(jWork.SelectToken("location.name"))) ? (string)jWork["location"]["name"] : null, description = (!JsonUtil.IsNullOrEmpty(jWork.SelectToken("/description"))) ? (string)jWork["description"] : null, position = (!JsonUtil.IsNullOrEmpty(jWork.SelectToken("position"))) ? (string)jWork["position"] : null }); } } catch (Exception e) { } try { JArray jTeams = (JArray)fbJson[FBFields.FAVORITE_TEAMS.ToString().ToLower()]; foreach (JObject jTeam in jTeams) { profileData.Interests.Add(new Interest() { name = (!JsonUtil.IsNullOrEmpty(jTeam.SelectToken("name"))) ? (string)jTeam["name"] : null, type = InterestType.TEAM }); } } catch (Exception e) { } try { JArray jAthletes = (JArray)fbJson[FBFields.FAVORITE_ATHLETES.ToString().ToLower()]; foreach (JObject jAthlete in jAthletes) { profileData.Interests.Add(new Interest() { name = (!JsonUtil.IsNullOrEmpty(jAthlete.SelectToken("name"))) ? (string)jAthlete["name"] : null, type = InterestType.ATHLETE }); } } catch(Exception e) { } return profileData; }
internal static ProfileData ParseLinkedInData(JObject jsonProfileData) { ProfileData profileData = new ProfileData() { ProfilePicUrl = (string)jsonProfileData[GetEnumDescription(LinkedInFields.PICTUREURL)], FirstName = (string)jsonProfileData[GetEnumDescription(LinkedInFields.FIRSTNAME)], LastName = (string)jsonProfileData[GetEnumDescription(LinkedInFields.LASTNAME)], Bio = (string)jsonProfileData[GetEnumDescription(LinkedInFields.SUMMARY)], About = (string)jsonProfileData[GetEnumDescription(LinkedInFields.HEADLINE)], ProfileLink = (string)jsonProfileData[GetEnumDescription(LinkedInFields.PUBLICPROFILEURL)], EmailAddress = (string)jsonProfileData[GetEnumDescription(LinkedInFields.EMAILADDRESS)] , Industry = (string)jsonProfileData[GetEnumDescription(LinkedInFields.INDUSTRY)] }; return profileData; }
public UserComparison() { EqualProfileData = new ProfileData(); OnlyUserProfileData = new ProfileData(); OnlyCompUserProfileData = new ProfileData(); }
public void SetProfileInfo(ProfileData profileData) { this.Gender = profileData.Gender; this.FirstName = profileData.FirstName; this.LastName = profileData.LastName; this.Age = profileData.Age; if(profileData.Bio != null) this.Bio = profileData.Bio; if (profileData.About != null) this.About = profileData.About; if (profileData.ProfilePicUrl != null) this.ProfilePicUrl = profileData.ProfilePicUrl; }
protected override void Load(ProfileData profileData) { //No loading action for this implementation }
abstract protected void Load(ProfileData profileData);