public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(value); } var currency = System.Convert.ToDouble(value); return(CultureProvider.FormatCurrency(currency)); }
public string GetFareEstimateDisplay(DirectionInfo direction) { var fareEstimate = _localize[_appSettings.Data.DestinationIsRequired ? "NoFareTextIfDestinationIsRequired" : "NoFareText"]; if (direction.ValidationResult != null && direction.ValidationResult.HasError) { fareEstimate = direction.ValidationResult.Message; } else if (direction.Distance.HasValue) { var willShowFare = direction.Price.HasValue && direction.Price.Value > 0; if (willShowFare) { var isOverMaxFare = direction.Price.Value > _appSettings.Data.MaxFareEstimate; var formattedCurrency = CultureProvider.FormatCurrency(direction.Price.Value); fareEstimate = String.Format( CultureProvider.CultureInfo, _localize[isOverMaxFare ? "EstimatePriceOver100" : "EstimatePriceFormat"], formattedCurrency, direction.FormattedDistance); } else { fareEstimate = _localize["EstimatedFareNotAvailable"]; } } return(fareEstimate); }