Guest User

Untitled

a guest
Sep 26th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. public class User
  2. {
  3. public User()
  4. {
  5. Name = string.Empty;
  6. LastName = string.Empty;
  7. }
  8.  
  9. public void SetInnerProperties()
  10. {
  11. S = string.Format("{0} {1} {0}", Name, LastName).ToUpper();
  12. T = Phones == null ? string.Empty : string.Join(" ", Phones.Select(x => x.Phone));
  13. //x.ToPhone() removes white spaces and non digit char
  14. }
  15.  
  16. public string Name { get; set; }
  17.  
  18. public string LastName { get; set; }
  19.  
  20. public List<PhoneNumber> Phones { get; set; }
  21.  
  22. public string S { get; set; }
  23.  
  24. public string T { get; set; }
  25.  
  26. public override string ToString()
  27. {
  28. return S;
  29. }
  30. }
  31.  
  32. public class PhoneNumber
  33. {
  34. public string Phone { get; set; }
  35.  
  36. public PhoneNumberType PhoneNumberType { get; set; }
  37. }
  38.  
  39. users.ForEach(x => x.SetInnerProperties());
  40.  
  41. if (isPhone)
  42. {
  43. var reqPhone = req.ToPhone();//remove white spaces and non digit char
  44. var resultPhone = users.Where(x => x.T.Contains(reqPhone)).Take(10);
  45. return resultPhone;
  46. }
  47. var reqUp = req.ToUpper();
  48. var result = users.Where(x => x.S.Contains(reqUp)).Take(10);
  49. return result;
Add Comment
Please, Sign In to add comment