private void LoadPurok() { var puroks = _repository.Purok.GetRange(); foreach (var purok in puroks) { var purokmodel = new PurokModel(purok, _repository); purokmodel.LoadRelatedInfo(); PurokList.Add(purokmodel); } }
private void DeletePurokProc() { var value = MessageBox.Show("Are you sure you want to delete this purok?", "Purok", MessageBoxButton.YesNo, MessageBoxImage.Question); if (value == MessageBoxResult.Yes) { var households = _repository.Household.GetRange(c => c.PurokNo == SelectedPurok.Model.PurokNo); if (households.Count > 0) { MessageBox.Show("Purok with households cannot be deleted"); } else { _repository.Purok.Remove(SelectedPurok.Model); PurokList.Remove(SelectedPurok); } } else { return; } }
private void SavePurokProc() { if (NewPurokModel == null) { return; } if (!NewPurokModel.HasChanges) { return; } try { _repository.Purok.Add(NewPurokModel.ModelCopy); var purokmodel = new PurokModel(NewPurokModel.ModelCopy, _repository); purokmodel.LoadRelatedInfo(); PurokList.Add(purokmodel); _addPurokWindow.Close(); } catch (Exception e) { MessageBox.Show("Unable to Save!", "Add Purok"); } }