using System;
using System.Collections.Generic;
using BS.Shared;

namespace BeWo.Data.Entities
{
	public class SupportConcept : BeWoEntityBase
	{
		public static string PropertyName_ApprovalDate = "ApprovalDate";

		public static string PropertyName_Conference = "Conference";

		public static string PropertyName_ConferenceDate = "ConferenceDate";

		public static string PropertyName_ConferenceVenue = "ConferenceVenue";

		public static string PropertyName_ConsultingNeeded = "ConsultingNeeded";

		public static string PropertyName_CostBearer2SupportConceptList = "CostBearer2SupportConceptList";

		public static string PropertyName_Customer = "Customer";

		public static string PropertyName_Originator = "Originator";

		public static string PropertyName_RenewalSendDate = "RenewalSendDate";

		public static string PropertyName_RequisitionSendDate = "RequisitionSendDate";

		public static string PropertyName_ServiceRecordList = "ServiceRecordList";

		public static string PropertyName_SupportConceptSendDate = "SupportConceptSendDate";

		public static string PropertyName_TaskList = "TaskList";

		public static string PropertyName_ValueList = "ValueList";

		public static string PropertyName_ServiceAccountings = "ServiceAccountings";

		private DateTime? _ApprovalDate;

		private bool? _Conference;

		private DateTime? _ConferenceDate;

		private string _ConferenceVenue;

		private bool? _ConsultingNeeded;

		private IList<CostBearer2SupportConcept> _CostBearer2SupportConceptList;

		private Customer _Customer;

		private Employee _Originator;

		private DateTime? _RenewalSendDate;

		private DateTime? _RequisitionSendDate;
		private IList<ServiceAccounting> _ServiceAccountings;

		private IList<ServiceRecord> _ServiceRecordList;

		private DateTime? _SupportConceptSendDate;

		private IList<Task> _TaskList;

		private IList<ValueListEntry2Object> _ValueList;

		public SupportConcept()
		{
			_Tid = TableID.SupportConcept;
		}

		public virtual DateTime? ApprovalDate
		{
			get { return _ApprovalDate; }

			set
			{
				if (AreDifferent(_ApprovalDate, value))
				{
					_ApprovalDate = value;
				}
			}
		}

		public virtual bool? Conference
		{
			get { return _Conference; }

			set
			{
				if (AreDifferent(_Conference, value))
				{
					_Conference = value;
				}
			}
		}

		public virtual DateTime? ConferenceDate
		{
			get { return _ConferenceDate; }

			set
			{
				if (AreDifferent(_ConferenceDate, value))
				{
					_ConferenceDate = value;
				}
			}
		}

		public virtual string ConferenceVenue
		{
			get { return _ConferenceVenue; }

			set
			{
				if (AreDifferent(_ConferenceVenue, value))
				{
					_ConferenceVenue = value;
				}
			}
		}

		public virtual bool? ConsultingNeeded
		{
			get { return _ConsultingNeeded; }

			set
			{
				if (AreDifferent(_ConsultingNeeded, value))
				{
					_ConsultingNeeded = value;
				}
			}
		}

		public virtual IList<CostBearer2SupportConcept> CostBearer2SupportConceptList
		{
			get
			{
				return _CostBearer2SupportConceptList ?? (_CostBearer2SupportConceptList = new List<CostBearer2SupportConcept>());
			}

			set
			{
				if (AreDifferent(_CostBearer2SupportConceptList, value))
				{
					_CostBearer2SupportConceptList = value;
				}
			}
		}

		public virtual IList<ServiceAccounting> ServiceAccountings
		{
			get { return _ServiceAccountings ?? (_ServiceAccountings = new List<ServiceAccounting>()); }

			set
			{
				if (AreDifferent(_ServiceAccountings, value))
				{
					_ServiceAccountings = value;
				}
			}
		}

		public virtual Customer Customer
		{
			get { return _Customer; }

			set
			{
				if (AreDifferent(_Customer, value))
				{
					_Customer = value;
				}
			}
		}

		public virtual DateTime? EndDate
		{
			get
			{
				DateTime? maxDate = null;

				foreach (CostBearer2SupportConcept cb in CostBearer2SupportConceptList)
				{
					DateTime? end = null;
					end = cb.ApprovedEndDate;

					if (end == null)
					{
						end = cb.RequestedEndDate;
					}

					if (maxDate == null || (end != null && end.Value > maxDate.Value))
					{
						maxDate = end;
					}
				}

				return maxDate;
			}
		}

		public virtual Employee Originator
		{
			get { return _Originator; }

			set
			{
				if (AreDifferent(_Originator, value))
				{
					_Originator = value;
				}
			}
		}

		public virtual DateTime? RenewalSendDate
		{
			get { return _RenewalSendDate; }

			set
			{
				if (AreDifferent(_RenewalSendDate, value))
				{
					_RenewalSendDate = value;
				}
			}
		}

		public virtual DateTime? RequisitionSendDate
		{
			get { return _RequisitionSendDate; }

			set
			{
				if (AreDifferent(_RequisitionSendDate, value))
				{
					_RequisitionSendDate = value;
				}
			}
		}

		public virtual IList<ServiceRecord> ServiceRecordList
		{
			get { return _ServiceRecordList ?? (_ServiceRecordList = new List<ServiceRecord>()); }

			set
			{
				if (AreDifferent(_ServiceRecordList, value))
				{
					_ServiceRecordList = value;
				}
			}
		}

		public virtual DateTime? StartDate
		{
			get
			{
				DateTime? minDate = null;

				foreach (CostBearer2SupportConcept cb in CostBearer2SupportConceptList)
				{
					DateTime? start = null;
					start = cb.ApprovedStartDate;

					if (start == null)
					{
						start = cb.RequestedStartDate;
					}

					if (minDate == null || (start != null && start.Value < minDate.Value))
					{
						minDate = start;
					}
				}

				return minDate;
			}
		}

		public virtual DateTime? SupportConceptSendDate
		{
			get { return _SupportConceptSendDate; }

			set
			{
				if (AreDifferent(_SupportConceptSendDate, value))
				{
					_SupportConceptSendDate = value;
				}
			}
		}

		public virtual IList<Task> TaskList
		{
			get { return _TaskList ?? (_TaskList = new List<Task>()); }

			set
			{
				if (AreDifferent(_TaskList, value))
				{
					_TaskList = value;
				}
			}
		}

		public virtual IList<ValueListEntry2Object> ValueList
		{
			get { return _ValueList ?? (_ValueList = new List<ValueListEntry2Object>()); }

			set
			{
				if (AreDifferent(_ValueList, value))
				{
					_ValueList = value;
				}
			}
		}
	}
}