Exemplo n.º 1
0
        public Transaction(
            DateTime transactionTime,
            String description,
            GlobalUnit globalUnit,
            CustomUnit customUnit,
            int[] entries,
            Entity entity,
            Session session,
            Action <Transaction> completion
            )
        {
            var newAttributes = new NewTransactionArguments(
                transactionTime,
                description,
                globalUnit,
                customUnit,
                entries
                );

            this.create(newAttributes, session, completion);
        }
        public NewTransactionArguments(
            DateTime transactionTime,
            String description,
            GlobalUnit globalUnit,
            CustomUnit customUnit,
            int[] entries
            )
        {
            if (globalUnit != null && customUnit != null)
            {
                throw new InvalidTransactionArguments(ErrTwoUnits);
            }

            if (globalUnit == null && customUnit == null)
            {
                throw new InvalidTransactionArguments(ErrTwoUnits);
            }

            if (entries == null || transactionTime == null)
            {
                throw new ArgumentNullException(ErrNullArgument);
            }

            if (description == null)
            {
                description = "";
            }

            if (description.Length > MaxDescriptionLength)
            {
                throw new InvalidTransactionArguments(ErrDescriptionLength);
            }

            this.transactionTime = transactionTime;
            this.description     = description;
            this.globalUnit      = globalUnit;
            this.customUnit      = customUnit;
            this.entries         = entries;
        }