Exemplo n.º 1
0
        public void ApplyVoucher(Voucher voucher)
        {
            if (voucher == null)
                throw new InvalidVoucherInstanceException();

            Apply(new VoucherAppliedToCart(CustomerId, voucher.Id, voucher.Amount));
        }
Exemplo n.º 2
0
        public static Voucher CreateVoucher(Guid customerId, Money amount, IVoucherCodeGenerator codeGenerator)
        {
            // Validate domain invariants
            if (customerId == Guid.Empty)
                throw new ArgumentNullException("customerId");

            var voucher = new Voucher();
            voucher.Apply(new VoucherCreated(Guid.NewGuid(), customerId, VoucherStatus.Created, amount, codeGenerator.GenerateCode(), DateTime.UtcNow.AddDays(14)));

            return voucher;
        }