Implemented LuxuryShippingCostCalculator.cs
This commit is contained in:
parent
d2424e2c67
commit
295192dcfa
1 changed files with 17 additions and 6 deletions
|
|
@ -9,16 +9,27 @@ namespace ShippingCosts.Implementations;
|
||||||
public sealed class LuxuryShippingCostCalculator(ICountryDistanceProvider countryDistanceProvider)
|
public sealed class LuxuryShippingCostCalculator(ICountryDistanceProvider countryDistanceProvider)
|
||||||
: ShippingCostCalculatorBase(countryDistanceProvider)
|
: ShippingCostCalculatorBase(countryDistanceProvider)
|
||||||
{
|
{
|
||||||
public override string CarrierName => string.Empty; // TODO
|
public override string CarrierName => "LuxuryShipping";
|
||||||
|
|
||||||
public override decimal? CalculateShippingCosts(string targetCountry, IMeasuredBox box)
|
public override decimal? CalculateShippingCosts(string targetCountry, IMeasuredBox box)
|
||||||
{
|
{
|
||||||
//const decimal MaxPrice = 4444M;
|
const decimal MaxPrice = 4444M;
|
||||||
|
|
||||||
// TODO
|
var countryInfo = CountryDistanceProvider.GetDistanceTo(targetCountry);
|
||||||
|
if (countryInfo == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
double width = ToCentimeters(box.Width);
|
||||||
|
double height = ToCentimeters(box.Height);
|
||||||
|
double depth = ToCentimeters(box.Depth);
|
||||||
|
|
||||||
//static double ToCentimeters(double millimeters) => millimeters / 10D;
|
double boxSizeCost = Math.Pow(width * height * depth, 2);
|
||||||
|
decimal totalCost = (decimal)(countryInfo.Value.ApproxDistance * boxSizeCost);
|
||||||
|
|
||||||
|
return Math.Min(totalCost, MaxPrice);
|
||||||
|
|
||||||
|
static double ToCentimeters(double millimeters) => millimeters / 10D;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue