Ejemplo n.º 1
0
        /// <summary>
        /// Changes user in dictionary
        /// </summary>
        /// <param name="dictionary">Dictionary to pass in</param>
        /// <param name="empID">Employee ID to change</param>
        /// <returns></returns>
        public Dictionary <int, Employee> ChangeUserInDictionary(Dictionary <int, Employee> dictionary, int empID)
        {
            PayrollConsoleReader payrollConsoleReader = new PayrollConsoleReader();

            try
            {
                if (dictionary.ContainsKey(empID))
                {
                    dictionary.Remove(empID, out Employee emp);
                    emp.FirstName   = payrollConsoleReader.GetFirstNameConsole();
                    emp.LastName    = payrollConsoleReader.GetLastNameConsole();
                    emp.HoursWorked = payrollConsoleReader.GetHoursWorkedConsole();
                    emp.Payrate     = payrollConsoleReader.GetPayrateConsole();
                    Console.WriteLine("Key: " + empID);
                    Console.WriteLine("Value: " + emp.FirstName + " " + emp.LastName);
                    dictionary.Add(empID, emp);
                }
                else
                {
                    Console.WriteLine("error!");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error {e}");
            }

            return(dictionary);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates an employee
        /// </summary>
        /// <param name="empID">The employee ID desired</param>
        /// <returns>An employee object</returns>
        public Employee CreateAnEmployee(int empID)
        {
            string  firstName;
            string  lastName;
            int     hoursWorked;
            decimal payrate;


            PayrollConsoleReader payrollConsoleReader = new PayrollConsoleReader();

            firstName   = payrollConsoleReader.GetFirstNameConsole();
            lastName    = payrollConsoleReader.GetLastNameConsole();
            hoursWorked = payrollConsoleReader.GetHoursWorkedConsole();
            payrate     = payrollConsoleReader.GetPayrateConsole();

            return(new Employee(firstName, lastName, empID, hoursWorked, payrate));
        }