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; }
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 }; }
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 }); }
public VoucherController(ISession session, IVoucherRepository voucherRepository, IVoucherCodeGenerator codeGenerator) { _session = session; _voucherRepository = voucherRepository; _codeGenerator = codeGenerator; }