PersonManager.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace MyClasses.PersonClasses
  7. {
  8. public class PersonManager
  9. {
  10. public Person CreatePerson(string first,
  11. string last,
  12. bool isSupervisor)
  13. {
  14. Person ret = null;
  15. if (!string.IsNullOrEmpty(first))
  16. {
  17. if (isSupervisor)
  18. {
  19. ret = new Supervisor();
  20. }
  21. else
  22. {
  23. ret = new Employee();
  24. }
  25. // Assign variables
  26. ret.FirstName = first;
  27. ret.LastName = last;
  28. }
  29. return ret;
  30. }
  31. /// <summary>
  32. /// This method simulates retrieving a list of Person object
  33. /// </summary>
  34. /// <returns>A collection of Person objets</returns>
  35. public List<Person> GetPeople()
  36. {
  37. List<Person> people = new List<Person>();
  38. people.Add(new Person() { FirstName = "Paul", LastName = "Sheriff" });
  39. people.Add(new Person() { FirstName = "John", LastName = "Kuhn" });
  40. people.Add(new Person() { FirstName = "Jim", LastName = "Rulh" });
  41. return people;
  42. }
  43. /// <summary>
  44. /// This method simulate retieving a list of Supervisor object
  45. /// </summary>
  46. /// <returns>A collection of Supervisor objects</returns>
  47. public List<Person> GetSupervisors()
  48. {
  49. List<Person> people = new List<Person>();
  50. people.Add(CreatePerson("Paul", "Sheriff", true));
  51. people.Add(CreatePerson("Michael", "Krasowski", true));
  52. return people;
  53. }
  54. /// <summary>
  55. /// This method simulates retrieving a list of Employee object
  56. /// </summary>
  57. /// <returns>A collection of Persons objects</returns>
  58. public List<Person> GetEmployees()
  59. {
  60. List<Person> people = new List<Person>();
  61. people.Add(CreatePerson("Steve", "Nystrom", false));
  62. people.Add(CreatePerson("John", "Kuhn", false));
  63. people.Add(CreatePerson("Jim", "Rulh", false));
  64. return people;
  65. }
  66. /// <summary>
  67. /// This method simulates retrieving a list of Supervisor and Employee object
  68. /// </summary>
  69. /// <returns>A collection of Supervisor and Employee objects</returns>
  70. public List<Person> GetSupervisorAndEmployees()
  71. {
  72. List<Person> people = new List<Person>();
  73. people.AddRange(GetEmployees());
  74. people.AddRange(GetSupervisors());
  75. return people;
  76. }
  77. }
  78. }