Skip to content
This repository was archived by the owner on Jan 21, 2022. It is now read-only.

Commit 65759f3

Browse files
Okay, let's gooo
1 parent 689a623 commit 65759f3

File tree

6 files changed

+45
-2
lines changed

6 files changed

+45
-2
lines changed

ViewModel/Helpers/Decisiontree/Methodes/InterestCheck.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ public static class InterestCheck
1616
/// <returns>return true if the potential match has atleast 1 interest otherwise return false</returns>
1717
public static bool CheckInterest(List<Interest> pf, List<Interest> loggedUser)
1818
{
19+
20+
if (pf == null)
21+
{
22+
return false;
23+
}
24+
1925
var sameInterest = pf.Where(item => loggedUser.Contains(item)).ToList();
2026

2127
if (sameInterest.Count >= 5)

ViewModel/Helpers/Decisiontree/Methodes/MoralCheck.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ public static bool CheckMoral(List<Moral> pf, List<Moral> loggedUser)
2020
//var sameMoral = pf.Where(item => loggedUser.Contains(item)).ToList();
2121
//var sameInterest = pf.Where(item => loggedUser.Contains(item)).ToList();
2222

23+
if (pf == null)
24+
{
25+
return false;
26+
}
2327
var sameMoral = MoralID(pf, loggedUser);
2428

2529
if (sameMoral.Count >= 5)

ViewModel/Helpers/Decisiontree/Methodes/MoralPercentageCheck.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ public static class MoralPercentageCheck
1717
public static bool CheckMoralPercentage(List<Moral> pf, List<Moral> loggedUser)
1818
{
1919

20+
if (pf == null)
21+
{
22+
return false;
23+
}
24+
25+
2026
var sameMoral = GetSameMorals(pf, loggedUser);
2127

2228
if (sameMoral.Count > 0)

ViewModel/Helpers/Decisiontree/Methodes/SameAgeCheck.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,25 @@ public static bool CheckSameAge(Profile pf, Profile liupf)
3434
/// <returns>true or false</returns>
3535
private static bool CheckAge(Profile pf, Profile liupf)
3636
{
37+
if (pf.Age == null || pf.Age == "")
38+
{
39+
pf.Age = "00";
40+
}
41+
3742
try
3843
{
39-
string pfAgeString = pf.Age.Substring(0, 2);
40-
string liupfAgeString = liupf.Age.Substring(0, 2);
44+
string pfAgeString = "";
45+
string liupfAgeString = "";
46+
try
47+
{
48+
pfAgeString = pf.Age.Substring(0, 2);
49+
liupfAgeString = liupf.Age.Substring(0, 2);
50+
51+
}
52+
catch (NullReferenceException ex)
53+
{
54+
return false;
55+
}
4156
int pfage = int.Parse(pfAgeString);
4257
int liupfAge = int.Parse(liupfAgeString);
4358
if (pfage >= (liupfAge - 2) && pfage <= (liupfAge + 2))

ViewModel/Helpers/Decisiontree/Methodes/SameCityCheck.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ public static class SameCityCheck
1515
/// <returns>true if they live is the same city and add 5 points to overall score, false if not in the same city</returns>
1616
public static bool CheckSameCity(Profile pf, Profile lipf)
1717
{
18+
19+
if (pf.City == null || pf.City == "")
20+
{
21+
return false;
22+
}
23+
1824
if (pf.City == lipf.City)
1925
{
2026
MainDecisionTree.Score += 5;

ViewModel/Helpers/Decisiontree/Methodes/SameSchoolCheck.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ public static class SameSchoolCheck
1515
/// <returns>true if schools are the same, false if schools are not the same</returns>
1616
public static bool CheckSameSchool(School pfSchool , School logedInUserSchool)
1717
{
18+
19+
if (pfSchool == null)
20+
{
21+
return false;
22+
}
23+
1824
if (pfSchool.SchoolName.Equals(logedInUserSchool.SchoolName))
1925
{
2026
MainDecisionTree.Score += 5;

0 commit comments

Comments
 (0)