private void Button_Click_AddDepartment(object sender, RoutedEventArgs e) { try { var temp = depdto; if (string.IsNullOrEmpty(temp.DepartmentName)) { MessageBox.Show("Departman adı boş olamaz!"); return; } if (string.IsNullOrEmpty(temp.DepartmentManager)) { MessageBox.Show("Departman yöneticisi boş olamaz!"); return; } ServiceAdapter.Instance.InsertDepartment(new DepartmentDto() { DepartmentName = temp.DepartmentName, DepartmentManager = temp.DepartmentManager }); MessageBox.Show("Kayıt başarıyla eklendi!"); DepartmentListPage nextPage = new DepartmentListPage(); NavigationService.Navigate(nextPage); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Button_Click_UpdateDepartment(object sender, RoutedEventArgs e) { try { depDto.DepartmentId = ServiceAdapter.Instance.GetDepartmentList().FirstOrDefault(x => x.DepartmentName == InitialDepartmentName).DepartmentId; ServiceAdapter.Instance.UpdateDepartment(new DepartmentDto() { DepartmentId = depDto.DepartmentId, DepartmentName = depDto.DepartmentName, DepartmentManager = depDto.DepartmentManager }); MessageBox.Show("Kaydınız başarılı şekilde güncellendi!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } DepartmentListPage nextPage = new DepartmentListPage(); NavigationService.Navigate(nextPage); }