Пример #1
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;
        }
Пример #2
0
        public static Voucher CreateVoucher(Guid customerId, Money amount, IVoucherCodeGenerator codeGenerator)
        {
            // Validate domain invariants
            if (customerId == Guid.Empty)
                throw new InvalidCustomerIdException();

            return new Voucher()
            {
                Id = Guid.NewGuid(),
                CustomerId = customerId,
                Code = codeGenerator.GenerateCode(),
                Status = VoucherStatus.Created,
                ExpirationDate = DateTime.UtcNow.AddDays(14),
                Amount = amount
            };
        }
Пример #3
0
        public static Voucher CreateVoucher(Guid customerId, Money amount, IVoucherCodeGenerator codeGenerator)
        {
            // Validate domain invariants
            if (customerId == Guid.Empty)
            {
                throw new InvalidCustomerIdException();
            }

            return(new Voucher()
            {
                Id = Guid.NewGuid(),
                CustomerId = customerId,
                Code = codeGenerator.GenerateCode(),
                Status = VoucherStatus.Created,
                ExpirationDate = DateTime.UtcNow.AddDays(14),
                Amount = amount
            });
        }
Пример #4
0
 public VoucherController(ISession session, IVoucherRepository voucherRepository, IVoucherCodeGenerator codeGenerator)
 {
     _session           = session;
     _voucherRepository = voucherRepository;
     _codeGenerator     = codeGenerator;
 }
Пример #5
0
 public VoucherController(ISession session, IVoucherRepository voucherRepository, IVoucherCodeGenerator codeGenerator)
 {
     _session = session;
     _voucherRepository = voucherRepository;
     _codeGenerator = codeGenerator;
 }