| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MyClasses.PersonClasses
- {
- public class PersonManager
- {
- public Person CreatePerson(string first,
- string last,
- bool isSupervisor)
- {
- Person ret = null;
- if (!string.IsNullOrEmpty(first))
- {
- if (isSupervisor)
- {
- ret = new Supervisor();
- }
- else
- {
- ret = new Employee();
- }
- // Assign variables
- ret.FirstName = first;
- ret.LastName = last;
- }
- return ret;
- }
- /// <summary>
- /// This method simulates retrieving a list of Person object
- /// </summary>
- /// <returns>A collection of Person objets</returns>
- public List<Person> GetPeople()
- {
- List<Person> people = new List<Person>();
- people.Add(new Person() { FirstName = "Paul", LastName = "Sheriff" });
- people.Add(new Person() { FirstName = "John", LastName = "Kuhn" });
- people.Add(new Person() { FirstName = "Jim", LastName = "Rulh" });
- return people;
- }
- /// <summary>
- /// This method simulate retieving a list of Supervisor object
- /// </summary>
- /// <returns>A collection of Supervisor objects</returns>
- public List<Person> GetSupervisors()
- {
- List<Person> people = new List<Person>();
- people.Add(CreatePerson("Paul", "Sheriff", true));
- people.Add(CreatePerson("Michael", "Krasowski", true));
- return people;
- }
- /// <summary>
- /// This method simulates retrieving a list of Employee object
- /// </summary>
- /// <returns>A collection of Persons objects</returns>
- public List<Person> GetEmployees()
- {
- List<Person> people = new List<Person>();
- people.Add(CreatePerson("Steve", "Nystrom", false));
- people.Add(CreatePerson("John", "Kuhn", false));
- people.Add(CreatePerson("Jim", "Rulh", false));
- return people;
- }
- /// <summary>
- /// This method simulates retrieving a list of Supervisor and Employee object
- /// </summary>
- /// <returns>A collection of Supervisor and Employee objects</returns>
- public List<Person> GetSupervisorAndEmployees()
- {
- List<Person> people = new List<Person>();
- people.AddRange(GetEmployees());
- people.AddRange(GetSupervisors());
- return people;
- }
- }
- }
|