コード例 #1
0
        // to Dapper mapping.
        protected Invoice(Guid invoiceId, decimal fee, decimal total, int paymentMethodId, Guid tripId, double distance,
                          TimeSpan duration, DateTime created, int tripStatusId, int status, string cardNumber, string cardType, int userId)
        {
            _invoiceId       = invoiceId;
            _created         = created;
            _tripInformation = new TripInformation(tripId, duration, distance, tripStatusId);
            _fee             = fee;
            _paymentMethod   = PaymentMethod.From(paymentMethodId);
            _total           = total;

            if (userId != default(int))
            {
                _paymentInfo = new PaymentInfo(userId, (PaymentStatus)status, cardNumber, cardType);
            }
        }
コード例 #2
0
        public Invoice(int paymentMethodId, Guid tripId, TimeSpan duration, double distance, int tripStatusId)
        {
            if (paymentMethodId == default(int))
            {
                throw new InvoiceDomainArgumentNullException(nameof(paymentMethodId));
            }

            _invoiceId       = Guid.NewGuid();
            _created         = DateTime.UtcNow;
            _paymentMethod   = PaymentMethod.From(paymentMethodId);
            _tripInformation = new TripInformation(tripId, duration, distance, tripStatusId);
            GetFee();
            GetTotal();

            AddDomainEvent(new InvoiceCreatedDomainEvent(_invoiceId, _fee, _total, Equals(_paymentMethod, PaymentMethod.CreditCard), _tripInformation.Id));
        }