private void WithdrawFromAccount() { decimal withdrawed = bankAccount.CoinsParser(); if (withdrawed <= bankAccount.AccountAmount) { bankAccount.AccountAmount -= withdrawed; Notify?.Invoke($"From Account Withdrawed {withdrawed} coins"); } else { NotifyError?.Invoke($"Insufficient Funds!"); } ShowMenu(); }
public bool Update(Company item) { if (item == null) { throw new InvalidOperationException("The company can't be null"); } var updated = false; var validationResult = _validator.Validate(item); if (validationResult.HasError) { NotifyError?.Invoke(this, validationResult); } else { updated = _repository.Update(item); } return(updated); }
public bool Create(Person item) { if (item == null) { throw new InvalidOperationException("The person to create can't be null"); } var created = false; var validationResult = _validator.Validate(item); if (validationResult.HasError) { NotifyError?.Invoke(this, validationResult); } else { created = _repository.Create(item); } return(created); }
private static NotifyError WriteLineError( TextWriter w, LogEventArgs e ) { Debug.Assert( typeof( ILogErrorCulprit ).IsAssignableFrom( typeof( ILogEventNotRunningError ) ) && typeof( ILogErrorCulprit ).IsAssignableFrom( typeof( ILogErrorCaught ) ), "These 2 interfaces both are ILogErrorCulprit." ); Debug.Assert( typeof( ILogErrorCaught ).IsAssignableFrom( typeof( ILogEventNotRunningError ) ) == false && typeof( ILogEventNotRunningError ).IsAssignableFrom( typeof( ILogErrorCaught ) ) == false, "These 2 interfaces are independant." ); var culprit = e as ILogErrorCulprit; if( culprit != null ) { NotifyError notif = new NotifyError(); notif.Title = String.Format( R.NotifiyErrorTitle, culprit.Culprit.DeclaringType.Name ); CrashLogWriter.WriteLineProperty( w, "Culprit", culprit.Culprit.DeclaringType.FullName + '.' + culprit.Culprit.Name ); var error = e as ILogErrorCaught; if( error != null ) { CrashLogWriter.WriteLineException( w, error.Error ); notif.Content = error.Error.Message; } else { var runningError = e as ILogEventNotRunningError; if( runningError != null ) { CrashLogWriter.WriteLineProperty( w, "ServiceStatus", runningError.ServiceIsDisabled ? "Disabled" : "Stopped" ); notif.Content = R.ErrorEventServiceStatus; } } return notif; } return null; }
void SafeNotifyError(string message, Exception ex) { NotifyError?.Invoke(message, ex); }