Exemplo n.º 1
0
        static void Main(string[] args)
        {
            File.Delete("Department.xml");
            File.Delete("Employee.xml");
            IRepository repo = new XmlRepository();

            Populate(repo);

            var employees = repo.Employees;

            PrintEmployees(employees);

            var emplArtur = repo.Employees.First(
                e => e.FirstName.Equals("Artur", StringComparison.InvariantCultureIgnoreCase)
                );

            emplArtur.Promote();
            repo.Save();
            PrintEmployees(repo.Employees);

            var engeneeringDepartment = new Department {
                Id = 4, Name = "Engineering"
            };

            repo.AddDepartment(engeneeringDepartment);
            repo.Save();
            PrintDepartments(repo.Departments);

            emplArtur.ChangeDepartment(engeneeringDepartment);
            repo.Save();
            PrintEmployees(repo.Employees);

            emplArtur.Demote();
            repo.Save();
            PrintEmployees(repo.Employees);

            var marcoCantu = employees.Single(e => e.FirstName.Equals("Marco") && e.SecondName.Equals("Cantu"));

            emplArtur.ChangeChief(marcoCantu);
            repo.Save();
            PrintEmployees(repo.Employees);

            Console.Read();
        }