private void btnSpremeni_Click(object sender, RoutedEventArgs e) { winCRU wc = (winCRU)Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive); winUporabnik winUpo = new winUporabnik(); winUpo.Owner = wc; winUpo.Uporabniki = _uporabniki[grdUporabniki.SelectedIndex]; wc.Opacity = 0.5; winUpo.ShowDialog(); }
private void btnBrisi_Click(object sender, RoutedEventArgs e) { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:31207/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); string sMessageBoxText = "Ali res želite izbrisati izbrane uporabnike?"; string sCaption = "Uporabniki"; var rsltMessageBox = Windows.winMessageBox.Show(sCaption, sMessageBoxText, MessageBoxButton.YesNo, MessageBoxImage.Warning); switch (rsltMessageBox) { case MessageBoxResult.Yes: foreach (var data in grdUporabniki.SelectedItems) { Uporabniki upo = data as Uporabniki; var response = client.PostAsJsonAsync("api/uporabniki/delete/", upo).Result; if (!response.IsSuccessStatusCode) { MessageBox.Show("Error Code" + response.StatusCode + " : Message - " + response.ReasonPhrase); } } using (new ucWaitCursor()) { winCRU wc = (winCRU)Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive); ucClass.ucNavigate(wc.mainContent, new ucUporabniki()); } break; case MessageBoxResult.No: /* ... */ break; case MessageBoxResult.Cancel: /* ... */ break; } }