示例#1
0
        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();
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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;
        }
示例#5
0
 void SafeNotifyError(string message, Exception ex)
 {
     NotifyError?.Invoke(message, ex);
 }