ParcelCosting MakeParcelCosting(IParcel parcel, ParcelCostingParameters costParams) { var result = new ParcelCosting { Parcel = parcel, CostingType = costParams.CostingType, ParcelCost = costParams.BaseCost }; var overweight = parcel.Weight - costParams.MaxWeight; if (overweight > 0) { result.ParcelCost += Math.Ceiling(overweight) * costParams.CostPerExtraKg; } return(result); }
bool ValidParcelCosting(IParcel parcel, ParcelCostingParameters costParams) => !costParams.DimensionsMax.HasValue || AllParcelDimensionsLessThan(parcel, costParams.DimensionsMax.Value);