public GiftAidHandler(IApplicableTaxSelector applicableTaxSelector, ICreateGiftAidDeclarationCommand createGiftAidDeclarationCommand, DonationConfig donationConfig, ILogger <GiftAidHandler> logger) { _applicableTaxSelector = applicableTaxSelector ?? throw new ArgumentNullException(nameof(applicableTaxSelector)); _createGiftAidDeclarationCommand = createGiftAidDeclarationCommand ?? throw new ArgumentNullException(nameof(createGiftAidDeclarationCommand)); _donationConfig = donationConfig ?? throw new ArgumentNullException(nameof(donationConfig)); _logger = logger; }
/// <inheritdoc /> public GiftAidRequestValidator(DonationConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } RuleFor(x => x.Amount) .NotEmpty() .GreaterThan(config.MinDonationAmount) .LessThan(config.MaxDonationAmount ?? decimal.MaxValue); }
/// <inheritdoc /> public DonationRequestValidator(DonationConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } RuleFor(x => x.Amount) .NotEmpty() // Note: This means the max value is not allowed, although if the value is null it should. .GreaterThanOrEqualTo(config.MinDonationAmount).LessThan(config.MaxDonationAmount ?? decimal.MaxValue); RuleFor(x => x.FirstName).NotEmpty(); RuleFor(x => x.LastName).NotEmpty(); RuleFor(x => x.PostCode).NotEmpty(); // TODO: Do proper postal code validation }
protected override void Load(ContainerBuilder builder) { builder.RegisterModule(new Infrastructure.Cqs.Module(ThisAssembly)); builder.RegisterModule(new Infrastructure.MediatR.Module(ThisAssembly)); builder.RegisterType <ApplicableTaxSelector>().As <IApplicableTaxSelector>().SingleInstance(); builder.RegisterType <TaxProcessorFactory>().As <ITaxProcessorFactory>().SingleInstance(); builder.Register(c => { // TODO: Validate settings. Use a startup task if needed. var configuration = c.Resolve <IConfiguration>(); var donationConfig = new DonationConfig(); // Note: If we require hot reloading, there are other ways to do it. configuration.Bind(DonationConfigKey, donationConfig); return(donationConfig); }).AsSelf().SingleInstance(); builder.Register(c => new LiteDatabase(@"MyData.db")).As <LiteDatabase>().SingleInstance(); }