/// <summary> /// Method to ADD Department /// </summary> /// <param name="Name">New Department Name</param> /// <param name="ParentName">New Department Parent</param> public void AddDepartment(string Name, string ParentName) { Department department = new Department(Name, ParentName); DepartmentsDb.Add(department); Department parent = DepartmentsDb.Find(x => x.DepartmentName == ParentName); parent.innerDepartments.Add(department); }
/// <summary> /// SET Department Values for Properties /// </summary> /// <param name="node">XML node to get Values</param> /// <param name="dept">Department to add Values</param> void DefineDepartmentClass(XmlNode node, Department dept) { dept.DepartmentName = Convert.ToString(node.Attributes.GetNamedItem("departmentName").Value); dept.ParentDepartment = Convert.ToString(node.Attributes.GetNamedItem("parentDepartment").Value); dept.Repository = this; if (node.Attributes.GetNamedItem("parentDepartment").Value != "") { foreach (Department d in DepartmentsDb) { if (d.DepartmentName == dept.ParentDepartment) { d.innerDepartments.Add(dept); } } } else { company.Add(dept); } DepartmentsDb.Add(dept); }