private void AddTerlaporAction(object obj) { var form = new AddViewTerlaporView(); if (obj != null) { var context = Mapper.Map <AddTerlaporViewModel>(obj as Terlapor); context.WindowClose = form.Close; form.DataContext = context; } else { form.DataContext = new AddTerlaporViewModel() { WindowClose = form.Close }; } form.ShowDialog(); var formVM = form.DataContext as AddTerlaporViewModel; if (formVM.DataValid && obj == null) { vm.AddTerlapor(formVM); } else if (formVM.DataValid && obj != null) { var terlapor = (Terlapor)obj; var model = (Terlapor)formVM; terlapor.Agama = model.Agama; terlapor.Alamat = model.Alamat; terlapor.Gender = model.Gender; terlapor.KekerasanDialami = model.KekerasanDialami; terlapor.Nama = model.Nama; terlapor.NamaPanggilan = model.NamaPanggilan; terlapor.NIK = model.NIK; terlapor.NoReq = model.NoReq; terlapor.Pekerjaan = model.Pekerjaan; terlapor.Pendidikan = model.Pendidikan; terlapor.Pernikahan = model.Pernikahan; terlapor.Suku = model.Suku; terlapor.TanggalLahir = model.TanggalLahir; terlapor.TempatLahir = model.TempatLahir; } Terlapors.Refresh(); }
private void AddPenangananAction(object obj) { var typeName = obj.GetType().Name; if (typeName.Contains("Terlapor")) { var terlapor = obj as TerlaporViewModel; var form = new PenangananView(); var penanganan = new Penanganan(terlapor, "Terlapor") { IdentiasId = terlapor.Id, WindowClose = form.Close }; form.DataContext = penanganan; form.ShowDialog(); if (!string.IsNullOrEmpty(penanganan.Layanan)) { terlapor.DataPenanganan.Add(penanganan); Terlapors.Refresh(); } else { MessageBox.Show("Data Tidak Valid", "Erro", MessageBoxButton.OK, MessageBoxImage.Error); } } else if (typeName.Contains("Korban")) { var korban = obj as Korban; var form = new PenangananView(); var penanganan = new Penanganan(korban, "Korban") { IdentiasId = korban.Id, WindowClose = form.Close }; form.DataContext = penanganan; form.ShowDialog(); if (!string.IsNullOrEmpty(penanganan.Layanan)) { korban.DataPenanganan.Add(penanganan); Korbans.Refresh(); } else { MessageBox.Show("Data Tidak Valid", "Erro", MessageBoxButton.OK, MessageBoxImage.Error); } } }