using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Windows.Data;

using BS.Shared;

using DevExpress.Utils;

namespace BeWo.Converter
{
    public class Rights2DefaultBooleanConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var tmp = DefaultBoolean.Default;

            var rightsList = new List<UserRightType>();
            if (parameter is String)
            {
                var rights = parameter.ToString().Split(',');

                rightsList.AddRange(rights.Select(rightString => (UserRightType) Enum.Parse(typeof (UserRightType), rightString.Trim())));

                tmp = BeWoApp.HasLoggedOnUserRight(rightsList.ToArray()) ? DefaultBoolean.True : DefaultBoolean.False;
            }

            return tmp;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}