Ejemplo n.º 1
0
        public void edit()
        {
            Console.WriteLine("\n\t╔═════════════════════════════════════╗");
            Console.WriteLine("\t║         EDITING A DEPARTMENT        ║");
            Console.WriteLine("\t╚═════════════════════════════════════╝");

            Console.WriteLine("\n\tWhich one would you like to edit? (type the id)");
            Console.Write("\n\t>>");
            int idToEdit = Convert.ToInt32(Console.ReadLine());

            Department specific = searchById(idToEdit);

            if (specific != null)
            {
                Console.WriteLine("{0}{1}", "\n\tID: ", specific.IdDepartament);
                Console.WriteLine("{0}{1}", "\tName: ", specific.DepartmentName);

                Console.Write("\n\tNew department name: ");
                specific.DepartmentName = Console.ReadLine();
                Seerializer.serializeDepartments(departmentList, "Departments.xml");
                Console.WriteLine("\n\t╔═══════════════════════════════════════════╗");
                Console.WriteLine("\t║        DEPARTMENT EDITED SUCCESSFULLY     ║");
                Console.WriteLine("\t╚═══════════════════════════════════════════╝");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("\n\t╔══════════════════════════════════════════════════════════╗");
                Console.WriteLine("\t║        THE DEPARTMENT YOU WANT TO EDIT WAS NOT FOUND     ║");
                Console.WriteLine("\t╚══════════════════════════════════════════════════════════╝");
                Console.ReadKey();
            }
        }
Ejemplo n.º 2
0
        public void delete()
        {
            Console.WriteLine("\n\t╔═══════════════════════════════════╗");
            Console.WriteLine("\t║       DELETING A DEPARTMENT       ║");
            Console.WriteLine("\t╚═══════════════════════════════════╝");

            Console.WriteLine("\n\tWhich one would you like to delete? (type the id)");
            Console.Write("\n\t>>");
            int idToDelete = Convert.ToInt32(Console.ReadLine());

            Department itemToRemove = departmentList.SingleOrDefault(r => r.IdDepartament == idToDelete);

            if (itemToRemove != null)
            {
                departmentList.Remove(itemToRemove);
                Seerializer.serializeDepartments(departmentList, "Departments.xml");
                Console.WriteLine("\n\t╔═══════════════════════════════════════════╗");
                Console.WriteLine("\t║       DEPARTMENT DELETED SUCCESSFULLY     ║");
                Console.WriteLine("\t╚═══════════════════════════════════════════╝");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("\n\t╔══════════════════════════════════════════════════════════╗");
                Console.WriteLine("\t║        THE DEPARTMENT YOU WANT TO DROP WAS NOT FOUND     ║");
                Console.WriteLine("\t╚══════════════════════════════════════════════════════════╝");
                Console.ReadKey();
            }
        }
Ejemplo n.º 3
0
        public void add()
        {
            Console.WriteLine("\n\t╔═════════════════════════════════════╗");
            Console.WriteLine("\t║       ADDING A NEW DEPARTMENT       ║");
            Console.WriteLine("\t╚═════════════════════════════════════╝");

            idDepartment++;
            departmet = new Department();
            departmet.IdDepartament = idDepartment;
            Console.Write("\n\tDepartment name: ");
            departmet.DepartmentName = Console.ReadLine();
            departmentList.Add(departmet);
            Seerializer.serializeDepartments(departmentList, "Departments.xml");
            Console.WriteLine("\n\t╔═══════════════════════════════════════════╗");
            Console.WriteLine("\t║     NEW DEPARTMENT ADDED SUCCESSFULLY     ║");
            Console.WriteLine("\t╚═══════════════════════════════════════════╝");
            Console.ReadKey();
        }