public IEnumerable <IProductDomainEntity> Create(ITariffCalculationSettings calculationSettings, params TariffType[] types) { var validateResult = _settingsValidator.Validate(calculationSettings); if (!validateResult.IsValid) { throw new ArgumentException(string.Join($"{Environment.NewLine}", validateResult.Errors)); } var tariffTypeMap = new Dictionary <TariffType, ITariffCalculationStrategy> { { TariffType.Base, new BaseTariffStrategy( calculationSettings.BaseMonthCost, calculationSettings.MonthsInYear, calculationSettings.ConsumptionCosts) }, { TariffType.Package, new PackageTariffStrategy( calculationSettings.ThresholdConsumption, calculationSettings.BaseCost, calculationSettings.AdditionalConsumptionCosts ) } }; return(types.Select(type => new ProductDomainEntity(type.ToDescriptionString(), tariffTypeMap[type]))); }
public ProductService(IProductFactory productFactory, ITariffCalculationSettings calculationSettings) { _calculationSettings = calculationSettings; _productFactory = productFactory; }