private void UpdateComponenta() { if (SelectedComponenta == null) { MessageBox.Show("Selecteaza o donatie..."); } else { var viewModel = new ComponentaDetailViewModel(SelectedComponenta); ComponentaMasterDetailView DetailPage = new ComponentaMasterDetailView(viewModel); DetailPage.Show(); viewModel.ComponentaUpdated += (source, componenta) => { var componentavm = new ComponentaViewModel(componenta); Componente.ToList().ForEach(d => { if (d.Id == componentavm.Id) { d = componentavm; d.Pacient.Nume = componentavm.Pacient.Nume; d.Pacient.Prenume = componentavm.Pacient.Prenume; } }); DetailPage.Close(); }; } }
public ComponentaDetailViewModel(ComponentaViewModel componentaViewModel) { ComponentaViewModel = componentaViewModel; CloseWindowCommand = new BasicCommandWithParameter(CloseWindow); SaveCommand = new BasicCommand(Save); Stari = new ObservableCollection <string>(); Tipuri = new ObservableCollection <string>(); foreach (var stare in Enum.GetValues(typeof(StareComponenta))) { if (stare.ToString().Equals("InAsteptare")) { Stari.Add("In Asteptare"); } else { Stari.Add(stare.ToString()); } } foreach (var tip in Enum.GetValues(typeof(TipComponenta))) { Tipuri.Add(tip.ToString()); } if (ComponentaViewModel.Pacient == null) { NumePrimitor = ""; } else { NumePrimitor = ComponentaViewModel.Pacient.Nume; } if (ComponentaViewModel.Pacient == null) { PrenumePrimitor = ""; } else { PrenumePrimitor = ComponentaViewModel.Pacient.Prenume; } SelectedStare = ComponentaViewModel.Stare; SelectedTip = ComponentaViewModel.TipComponenta; DataDepunere = ComponentaViewModel.DataDepunere; }