You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
729 B
21 lines
729 B
using System;
|
|
using System.Globalization;
|
|
using System.Windows.Data;
|
|
|
|
namespace BBWYB.Client.Converters
|
|
{
|
|
public class ProfitRatioConverter : IMultiValueConverter
|
|
{
|
|
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
decimal.TryParse(values[0]?.ToString(), out decimal profit);
|
|
decimal.TryParse(values[1]?.ToString(), out decimal totalCost);
|
|
return totalCost == 0 ? "0" : Math.Round(profit / totalCost * 100, 2).ToString();
|
|
}
|
|
|
|
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|
|
|