using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using BS.Shared;

namespace BeWo.Converter
{
	public class ReactivationRight2VisibilityConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (parameter == null)
			{
				return Visibility.Collapsed;
			}

			var hasRight = false;

			switch (parameter.ToString())
			{
				case "Person":
					hasRight = BeWoApp.LoggedOnUser.HasRight(UserRightType.PersonAllowReactivation);
					break;
				case "Organisation":
					hasRight = BeWoApp.LoggedOnUser.HasRight(UserRightType.OrganisationAllowReactivation);
					break;
				case "SupportConcept":
					hasRight = BeWoApp.LoggedOnUser.HasRight(UserRightType.SupportConceptAllowReactivation);
					break;
				case "Customer":
					hasRight = BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerAllowReactivation);
					break;
			}

			return (bool)value && hasRight ? Visibility.Visible : Visibility.Collapsed;
		}

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