-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParseObject.cs
52 lines (41 loc) · 1.57 KB
/
ParseObject.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using JsonTest.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JsonTest
{
public class ParseObject
{
public ParseObject()
{ }
public List<string> Handle(Recipents result)
{
List<Recipent> listMoreThanOne = result.recipients.Where(x => x.tags.Count > 1).ToList();
List<string> listMatchedUser = new List<string>();
if (listMoreThanOne.Count == 0)
return listMatchedUser;
int row = listMoreThanOne.Count;
int count = 0;
while (count < row)
{
for (int i = count + 1; i < row; i++)
{
var list1 = listMoreThanOne[count].tags;
var list2 = listMoreThanOne[i].tags;
var match = list1.Where(x => list2.Any(z => z.Equals(x)));
if (match.Count() > 1)
{
string matchUsersName = string.Format("{0},{1}", listMoreThanOne[count].name, listMoreThanOne[i].name);
string repeatedUsersName = string.Format("{0},{1}", listMoreThanOne[i].name, result.recipients[count].name);
if (!listMatchedUser.Contains(matchUsersName) && !listMatchedUser.Contains(repeatedUsersName))
listMatchedUser.Add(matchUsersName);
}
}
count++;
}
return listMatchedUser;
}
}
}