Esempio n. 1
0
        private void AddEmployeeFile(EmployeeBase employee)
        {
            List<EmployeeBase> employees;

            try
            {
                employees = GetEmployeesFromFile();
            }
            catch (FileNotFoundException ex)
            {
                employees = new List<EmployeeBase>();
            }

            employee.Id = employees.Count == 0 ? 0 : employees.Max(x => x.Id) + 1;
            employees.Add(employee);

            XmlSerializer xmlserialazer = new XmlSerializer(typeof(List<EmployeeBase>));

            using (TextWriter myStreamWriter = new StreamWriter(filePath))
            {
                xmlserialazer.Serialize(myStreamWriter, employees);
            }
        }
Esempio n. 2
0
 private void AddEmployeeBd(EmployeeBase employee)
 {
     employeeRepository.Add(Mapper.Map<Employee>(employee));
 }