/// <summary> /// Called when this instance is loaded. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private async void OnLoaded(object sender, RoutedEventArgs e) { if (DesignerProperties.GetIsInDesignMode(this)) { return; } this.Cursor = Cursors.Wait; this.IsEnabled = false; this.employee = null; using (IDataService service = new FileDataService()) { this.employee = await service.GetEmployeeByIdAsync(this.EmployeeId); } this.Cursor = Cursors.None; this.IsEnabled = true; if (this.employee == null) { return; } this.DataContext = this.employee; }
/// <summary> /// Loads an employee. /// </summary> public async void LoadEmployee() { this.IsEnabled = false; this.Employee = null; using (IDataService service = new FileDataService()) { this.Employee = await service.GetEmployeeByIdAsync(this.EmployeeId); } this.IsEnabled = true; }
/// <summary> /// Called when this instance is loaded. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private async void OnLoaded(object sender, RoutedEventArgs e) { if (DesignerProperties.GetIsInDesignMode(this)) { return; } this.Cursor = Cursors.Wait; this.IsEnabled = false; this.employee = null; using (IDataService service = new FileDataService()) { this.employee = await service.GetEmployeeByIdAsync(this.EmployeeId); } this.Cursor = Cursors.None; this.IsEnabled = true; if (this.employee == null) { return; } this.FirstNameTextBox.Text = this.employee.FirstName; this.LastNameTextBox.Text = this.employee.LastName; this.TitleTextBox.Text = this.employee.Title; this.BirthDateDatePicker.SelectedDate = this.employee.BirthDate; this.HireDateDatePicker.SelectedDate = this.employee.HireDate; this.AddressTextBox.Text = this.employee.Address; this.CityTextBox.Text = this.employee.City; this.StateTextBox.Text = this.employee.State; this.CountryTextBox.Text = this.employee.Country; this.PostalCodeTextBox.Text = this.employee.PostalCode; this.PhoneTextBox.Text = this.employee.Phone; this.FaxTextBox.Text = this.employee.Fax; }