public FormatProductPriceCalculation( Product.ProductType productType, OrderParameter orderParameter, ProductCalculationResult calculationResult) { _productType = productType; _orderParameter = orderParameter; _calculationResult = calculationResult; }
public ProductCalculationResult Calculate() { var result = new ProductCalculationResult(); try { result.SheetsSizes = new List <Product.SheetSizes>(Calculation.CalculateSheetSizes(_orderParameter.CorrugationType, _productType)); result.ProductPrice = (result.ProductArea * _orderParameter.CardboardPrice).Round(2); result.IsValid = true; if (_orderParameter.ShouldCalculateStampPrice && _orderParameter.PricePerKnifeMeter.HasValue) { result.StampPrice = (Calculation.CalculateStampKnivesLength(_orderParameter.CorrugationType, _productType) * _orderParameter.PricePerKnifeMeter.Value).Round(2); } } catch (Calculation.ProductTypeNoFormulaException) { return(ProductCalculationResult.GetCalculationErrorResult("Не найдена формула для данного типа картона")); } catch (Calculation.ProductTypeExpressionHasErrorException e) { return(ProductCalculationResult.GetCalculationErrorResult($"В процессе расчета формулы произошла ошибка:\n{e.Message}")); } return(result); }