private void delete(object sender, RoutedEventArgs e) { if (isNewResource) { NavigationService.Navigate(new Page()); return; } ResourceView newResource = null; foreach (var resource in ResourcePage.ResourceList) { if (resource.Id == Int32.Parse(idLabel.Content.ToString())) { newResource = resource; break; } } MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Da li ste sigurni da zelite da izbrišete ovaj resurs?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { if (_resourceController.Get(newResource.Id) != null) { _resourceController.Remove(newResource.Convert().Id); } ResourcePage.ResourceList.Remove(newResource); System.Windows.MessageBox.Show("Promene uspešno sačuvane"); NavigationService.Navigate(new Page()); return; } }
private void button_Copy_Click(object sender, RoutedEventArgs e) { ResourceView newResource = new ResourceView(); Resource resource = new Resource(); if (!isNewResource) { foreach (var _resource in ResourcePage.ResourceList) { if (_resource.Id == Int32.Parse(idLabel.Content.ToString())) { newResource = _resource; break; } } } else { newResource.Id = resource.Id; } if (nameTextBox.Text.Length == 0) { System.Windows.MessageBox.Show("Unesite pravilno ime materijala."); return; } var s = roomsComboBox.SelectedItem as RoomView; if (!isNewResource) { ResourcePage.ResourceList.Remove(newResource); } newResource.RoomId = (int)s.Id; newResource.Type = nameTextBox.Text; resource = newResource.Convert(); if (!isNewResource) { _resourceController.Update(resource); } else { _resourceController.Add(resource); } ResourcePage.ResourceList.Add(newResource); System.Windows.MessageBox.Show("Uspešno ste sačuvali informacije."); NavigationService.Navigate(new Page()); }