public static void Display() { EmployeeContainer employeeContainer = EmployeeContainer.Inst; List <Employee> employees = employeeContainer.GetEmployees(); Console.WriteLine("Employees in system:"); string roleType = String.Empty; foreach (Employee emp in employees) { if (emp.GetType() == typeof(Developer)) { Console.WriteLine(emp.Id + ":" + Roles.Developer + "," + emp.FirstName + "," + emp.LastName + "," + emp.Age); } else if (emp.GetType() == typeof(CEO)) { Console.WriteLine(emp.Id + ":" + Roles.CEO + "," + emp.FirstName + "," + emp.LastName + "," + emp.Age); } else if (emp.GetType() == typeof(SoftwareTester)) { Console.WriteLine(emp.Id + ":" + Roles.SoftwareTester + "," + emp.FirstName + "," + emp.LastName + "," + emp.Age); } else if (emp.GetType() == typeof(Designer)) { Console.WriteLine(emp.Id + ":" + Roles.Designer + "," + emp.FirstName + "," + emp.LastName + "," + emp.Age); } else if (emp.GetType() == typeof(ProjectManager)) { Console.WriteLine(emp.Id + ":" + Roles.ProjectManager + "," + emp.FirstName + "," + emp.LastName + "," + emp.Age); } } }
public static void List() { EmployeeContainer employeeContainer = EmployeeContainer.Inst; List <Employee> employees = employeeContainer.GetEmployees(); foreach (Employee emp in employees) { if (emp.GetType() == typeof(Developer)) { Console.WriteLine(emp.Id + ":" + Roles.Developer + "," + emp.FirstName + "," + emp.LastName + "," + emp.Age); } else if (emp.GetType() == typeof(ProjectManager)) { Console.WriteLine(emp.Id + ":" + Roles.ProjectManager + "," + emp.FirstName + "," + emp.LastName + "," + emp.Age); } else if (emp.GetType() == typeof(SoftwareTester)) { Console.WriteLine(emp.Id + ":" + Roles.SoftwareTester + "," + emp.FirstName + "," + emp.LastName + "," + emp.Age); } else if (emp.GetType() == typeof(Designer)) { Console.WriteLine(emp.Id + ":" + Roles.Designer + "," + emp.FirstName + "," + emp.LastName + "," + emp.Age); } } }
// GET: Suppliers public ActionResult Index() { var employees = EmployeeContainer.GetEmployees(); var markets = MarketContainer.GetMarkets(); foreach (var emp in employees) { emp.MarketName = markets.FirstOrDefault(x => x.ID == emp.MagazinID).Denumire; } return(View(employees)); }
public static void RoleList(string operation) { EmployeeContainer employeeContainer = EmployeeContainer.Inst; List <Employee> employees = employeeContainer.GetEmployees(); if (operation.Equals("PMLIST", StringComparison.CurrentCultureIgnoreCase)) { foreach (ProjectManager p in employees.OfType <ProjectManager>()) { Console.WriteLine(p.Id + ":" + p.FirstName + "," + p.LastName + "," + p.Age + "," + p.Project); } } else if (operation.Equals("DEVLIST", StringComparison.CurrentCultureIgnoreCase)) { foreach (Developer d in employees.OfType <Developer>()) { Console.WriteLine(d.Id + ":" + d.FirstName + "," + d.LastName + "," + d.Age + "," + d.Project + "," + d.IsStudent); } } else if (operation.Equals("STLIST", StringComparison.CurrentCultureIgnoreCase)) { foreach (SoftwareTester s in employees.OfType <SoftwareTester>()) { Console.WriteLine(s.Id + ":" + s.FirstName + "," + s.LastName + "," + s.Age + "," + s.Project + "," + s.UsesAutomatedTests); } } else if (operation.Equals("DSNRLIST", StringComparison.CurrentCultureIgnoreCase)) { foreach (Designer d in employees.OfType <Designer>()) { Console.WriteLine(d.Id + ":" + d.FirstName + "," + d.LastName + "," + d.Age + "," + d.Project + "," + d.CanDraw); } } else if (operation.Equals("CEOLIST", StringComparison.CurrentCultureIgnoreCase)) { foreach (CEO c in employees.OfType <CEO>()) { Console.WriteLine(c.Id + ":" + c.FirstName + "," + c.LastName + "," + c.Age + "," + c.CeoYears); } } }
public static void Remove() { EmployeeContainer employeeContainer = EmployeeContainer.Inst; List <Employee> employees = employeeContainer.GetEmployees(); Validation validation = new Validation(); string id = String.Empty; do { Console.Write("Enter id of employee you want to delete:"); id = Console.ReadLine(); validation.CheckIntegerInput(id); } while (!validation.inputIsValid); Int32.TryParse(id, out int intId); for (int i = employees.Count - 1; i >= 0; i--) { if (employees[i].Id == intId) { employeeContainer.DeleteEmployee(employees[i]); Console.WriteLine("Employee deleted"); } } }