public List <XElement> SearchEmployeeNode(string pEmployeeBeforeEditName, string pCompanyValue, string pDepartmentValue) { var employee = Xdoc.Elements("Ramais").Elements("Empresa").Where(i => i.Attribute("id").Value.Equals(pCompanyValue)).FirstOrDefault() .Elements("Funcionario").Where(e => e.Element("Nome").Value == pEmployeeBeforeEditName && e.Element("Departamento").Value == pDepartmentValue); return(employee.ToList()); }
public List <XElement> SearchEmployeeNode(string pEmployeeBeforeEditName, string pCompany) { var employee = Xdoc.Elements("Telefones").Elements("Empresa").Where(i => i.Attribute("id").Value == pCompany).FirstOrDefault() .Elements("Funcionario").Where(e => e.Element("Nome").Value == pEmployeeBeforeEditName); return(employee.ToList()); }
public void AddNewEmployee(Employee pEmployee, string company) { var employeeXElement = new List <XElement>(); employeeXElement.Add(new XElement("Nome", pEmployee.Name)); employeeXElement.Add(new XElement("Tel1", pEmployee.MobilePhone)); employeeXElement.Add(new XElement("Tel2", pEmployee.TelePhone)); var companyNode = Xdoc.Elements("Telefones").Elements("Empresa").Where(i => i.Attribute("id").Value == company).First(); companyNode.Add(new XElement("Funcionario")); companyNode.Elements("Funcionario").Last().Add(employeeXElement); SaveXMLFIle("adicionou", pEmployee, company); }
public List <Employee> LoadEmployee(string pRootNode, string pFirstNodeName, string pFirstNodeValue) { List <Employee> listEmployees = new List <Employee>(); var employees = Xdoc.Elements(pRootNode).Elements(pFirstNodeName).Where(i => i.Attribute("id").Value.Equals(pFirstNodeValue)).FirstOrDefault(); if (employees != null) { employees.Elements().ToList().ForEach(i => listEmployees.Add(new Employee { Name = i.Element("Nome").Value, MobilePhone = i.Element("Tel1").Value, TelePhone = i.Element("Tel2").Value })); } return(listEmployees.OrderBy(i => i.Name).ToList()); }
public void AddNewEmployee(Employee pEmployee, string company, string pDepartment) { var employeeXElement = new List <XElement>(); employeeXElement.Add(new XElement("Nome", pEmployee.Name)); employeeXElement.Add(new XElement("Sigla", pEmployee.Initials)); employeeXElement.Add(new XElement("Local", pEmployee.Local)); employeeXElement.Add(new XElement("Ramal", pEmployee.ExtentionLine)); employeeXElement.Add(new XElement("Departamento", pDepartment)); var companyNode = Xdoc.Elements("Ramais").Elements("Empresa").Where(i => i.Attribute("id").Value == company).First(); companyNode.Add(new XElement("Funcionario")); companyNode.Elements("Funcionario").Last().Add(employeeXElement); SaveXMLFIle("adicionou", pEmployee, company, pDepartment); }
public List <Employee> LoadEmployee(string pRootNode, string pFirstNodeName, string pFirstNodeValue, string pFirstNodeAttributeName, string pFirstNodeAttributeValue) { List <Employee> listEmployees = new List <Employee>(); var employees = Xdoc.Elements(pRootNode).Elements(pFirstNodeName).Where(i => i.Attribute("id").Value == pFirstNodeValue).FirstOrDefault(); if (employees != null) { employees.Elements().Where(i => i.Element(pFirstNodeAttributeName).Value.Equals(pFirstNodeAttributeValue)).ToList() .ForEach(i => listEmployees.Add(new Employee { Name = i.Element("Nome").Value, Initials = i.Element("Sigla").Value, Local = i.Element("Local").Value, ExtentionLine = i.Element("Ramal").Value, Department = i.Element("Departamento").Value })); } return(listEmployees.OrderBy(i => i.Name).ToList()); }
public IEnumerable <XElement> Elements(XName xname) { return(Xdoc.Elements(xname)); }