using System;
using System.Linq;
using System.Runtime.Serialization;

namespace DebriefingSoftware.Common.Business.Filtering
{
	[Serializable]
	[DataContract]
	public class FilterParameter
	{
		public FilterParameter()
		{
			this.Group = string.Empty;
			this.OperationGroup = string.Empty;
			this.BinaryOperationGroup = string.Empty;
			this.FieldName = string.Empty;
		}

		[DataMember]
		public CaseSensitivity CaseSensitive { get; set; }

		[DataMember]
		public SqlOperationType OperationType { get; set; }

		[DataMember]
		public SqlDataType DataType { get; set; }

		private string _group;

		[DataMember]
		public string Group { get { return _group; } set { _group = value.ToLower(); } }

		private string _operationGroup;

		[DataMember]
		public string OperationGroup { get { return _operationGroup; } set { _operationGroup = value.ToLower(); } }

		private string _binaryOperationGroup;

		[DataMember]
		public string BinaryOperationGroup { get { return _binaryOperationGroup; } set { _binaryOperationGroup = value.ToLower(); } }

		[DataMember]
		public BinaryOperationDirection BinaryOperationArgument { get; set; }

		private string _fieldName;

		[DataMember]
		public string FieldName { get { return _fieldName; } set { _fieldName = value.ToLower(); } }

		[DataMember]
		public string[] FieldValues { get; set; }

		[DataMember]
		public FilterControlType ControlType { get; set; }

		[DataMember]
		public string ControlClientID { get; set; }

		public string GetJsonString()
		{
			return DataContractJsonSerializationHelper.Serialize(this);
		}
	}
}
