Exemplo n.º 1
0
        public static AbstractTransaction Create(String transactionType)
        {
            AbstractTransaction transaction;

            if (typeof(InstantTransaction).Name == transactionType)
            {
                transaction = InstantTransaction.Create();
            }
            else if (typeof(DeferredTransaction).Name == transactionType)
            {
                transaction = DeferredTransaction.Create();
            }
            else if (typeof(PermanentTransaction).Name == transactionType)
            {
                transaction = PermanentTransaction.Create();
            }
            else
            {
                throw new ArgumentException($"No transaction type corresponding to {transactionType}");
            }
            return(transaction);
        }
Exemplo n.º 2
0
        public static AbstractTransaction Create(DateTime?startDate = null, DateTime?endDate = null)
        {
            AbstractTransaction transaction = null;

            if (startDate == null)
            {
                transaction = InstantTransaction.Create();
            }
            else if (startDate > DateTime.Now && endDate == null)
            {
                transaction = DeferredTransaction.CreateDeferred(startDate);
            }
            else if (startDate < endDate && startDate > DateTime.Now)
            {
                transaction = PermanentTransaction.CreatePermanent(startDate, endDate);
            }
            else
            {
                IO.DisplayWarning("There is something wrong with the date.");
                throw new ArgumentException("No transaction can be executed from date " + startDate + " to " + endDate);
            }
            return(transaction);
        }