private void SeedData() { this.Add(EmployeeObjectFactory.CreateNewEmployeeObject("Devin", "Smith", 60000, 'm', false)); this.Add(EmployeeObjectFactory.CreateNewEmployeeObject("Andrew", "Jones", 40000, 'm', false)); this.Add(EmployeeObjectFactory.CreateNewEmployeeObject("Brenda", "Anderson", 100000, 'f', true)); this.Add(EmployeeObjectFactory.CreateNewEmployeeObject("Angela", "Roberts", 30000, 'f', false)); }
static void Main(string[] args) { bool endApplication = false; Employees employees = new Employees(); EmployeeRecordsView employeeRecordsView = EmployeeObjectFactory.EmployeeRecordsViewObject(employees); while (!endApplication) { Console.Clear(); Console.WriteLine(EmployeeCommonOutputText.GetApplicationHeading()); employeeRecordsView.RunRecordsView(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(EmployeeCommonOutputText.GetInstructions()); ConsoleKey instructionKey = Console.ReadKey().Key; switch (instructionKey) { case ConsoleKey.C: EmployeeCreateView employeeCreateView = EmployeeObjectFactory.EmployeeCreateViewObject(employees); employeeCreateView.RunCreateView(); break; case ConsoleKey.R: EmployeeReadView employeeReadView = EmployeeObjectFactory.EmployeeReadViewObject(employees); employeeReadView.RunReadView(); break; case ConsoleKey.U: Console.Clear(); Console.WriteLine("Update functionality not yet implemented."); Console.ReadKey(); break; case ConsoleKey.D: Console.Clear(); Console.WriteLine("Delete functionality not yet implemented."); Console.ReadKey(); break; default: endApplication = true; break; } } Console.ReadKey(); }
public void RunCreateView() { string firstName = null; string lastName = null; decimal annualSalary = 0; char gender = '\0'; bool isManager = false; Console.Clear(); Console.WriteLine(EmployeeCommonOutputText.GetApplicationHeading()); Console.WriteLine(); Console.WriteLine(EmployeeCommonOutputText.GetCreateHeading()); Console.Write("First Name: "); firstName = Console.ReadLine(); Console.Write("Last Name: "); lastName = Console.ReadLine(); Console.Write("Annual Salary: "); annualSalary = decimal.Parse(Console.ReadLine(), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture); Console.Write("Gender (m/f): "); gender = Convert.ToChar(Console.ReadLine()); Console.Write("Manager (true/false): "); isManager = Convert.ToBoolean(Console.ReadLine()); Console.WriteLine(); Console.WriteLine("Please press the [S] key to save the new employee record to the system or any other key to cancel."); ConsoleKey consoleKey = Console.ReadKey().Key; if (consoleKey == ConsoleKey.S) { _employees.Add(EmployeeObjectFactory.CreateNewEmployeeObject(firstName, lastName, annualSalary, gender, isManager)); } }