using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; using Tango.BL.Entities; using Tango.MachineStudio.DB.ViewModels; namespace Tango.MachineStudio.DB.Converters { /// /// Converts user role to string. /// /// public class UsersRolesToStringConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) return ""; if (value is IEnumerable) { IEnumerable userRoles = value as IEnumerable; return String.Join(", ", userRoles.Select(x => x.Role.Name)); } else { IEnumerable> userRoles = value as IEnumerable>; return String.Join(", ", userRoles.Where(x => x.IsSelected).Select(x => x.Entity.Name)); } } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }