using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using SimpleCRM.ViewDAO;
using SimpleCRM.Service;

namespace SimpleCRM.Convert
{
    public class CustomerNameConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string displayName = string.Empty;
            DictionarysService os = new DictionarysService();
            var w = os.GetAllCustomers().Where(item => item.ID == Int32.Parse(value.ToString()));
            if (w.Any())
            {
                return w.FirstOrDefault().Name;
            }

            return displayName;
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
