public EmployeeDto getEmployeeById(int employeeId) { EmployeeDto employee = new EmployeeDto(); if (employeeId > 0) { using (var _context = new NorthwindEntities()) { Employee empl = _context.Employees.First(x => x.EmployeeID == employeeId); employee = new EmployeeDto() { EmployeeId = empl.EmployeeID, Vorname = empl.FirstName, Nachname = empl.LastName, Adresse = empl.Address, Stadt = empl.City, PLZ = empl.PostalCode, Land = empl.Country, Geburtsdatum = empl.BirthDate, Einstellungsdatum = empl.HireDate, Telefon = empl.HomePhone }; } } return employee; }
private void Window_Loaded(object sender, RoutedEventArgs e) { using (NorthwindEntities _context = new NorthwindEntities()) { Employee empl = _context.Employees.First(x => x.EmployeeID == this.EmployeeId); _employee = new EmployeeDto() { EmployeeId = empl.EmployeeID, Vorname = empl.FirstName, Nachname = empl.LastName, Adresse = empl.Address, Stadt = empl.City, PLZ = empl.PostalCode, Land = empl.Country, Geburtsdatum = empl.BirthDate, Einstellungsdatum = empl.HireDate, Telefon = empl.HomePhone }; this.DataContext = _employee; } }