private void Export() { AllowInput = false; try { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "JSON|*.json"; sfd.DefaultExt = "json"; if (sfd.ShowDialog() == true) { FileExporter.FileExporter.ExportTransactionType(sfd.FileName, TransactionTypes.Where(c => TransactionTypesView.Filter(c)).ToList()); } } catch (IOException e) { MessageBox.Show("Unexpected error occurred while loading JSON file. Details:/n" + e.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } catch (Exception) { MessageBox.Show("Unexpected error occurred while importing", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { AllowInput = true; } }
protected override void FormValidationRules() { if (StartValidating) { if (Name != null) { if (string.IsNullOrWhiteSpace(Name)) { AppendError("Name", "Name cannot be empty"); } else if (TransactionTypes.Where(tt => TransactionType == null || tt.Id != TransactionType.Id).Any(tt => tt.Name == Name)) { AppendError("Name", "Name must be unique"); } } RaiseErrorsChanged("Name"); if (isColorBoxDirty && Color == null) { AppendError("Color", "Color must be selected"); } RaiseErrorsChanged("Color"); } }
public ApiTransactionType GetTransactionType(int id) { return(TransactionTypes.Where(x => x.Id == id).FirstOrDefault()); }