using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.DCEntityMapper;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;

namespace BeWo.Service.Plugins
{
	public class UiElementFactory : AbstractIDSpecificDefaultClass<UiElementFactory>
	{
		public virtual IList<UiElementDC> GetUiElements(UiElementType? uiType, long? employeeOid, long? teamOid)
		{
			var allUiElements = DAOFactory.GenericDAO.GetAllActive<UiElement>();

			var filteredElements = allUiElements.Where(ui =>
			{
				var contains = true;
				if (uiType.HasValue)
				{
					contains = ui.UiElementType == uiType.Value;
				}
				if (contains && employeeOid.HasValue && ui.EmployeeOid.HasValue)
				{
					contains = ui.EmployeeOid.Value == employeeOid.Value;
				}
				if (contains && teamOid.HasValue && ui.TeamOid.HasValue)
				{
					contains = ui.TeamOid.Value == teamOid.Value;
				}

				return contains;
			});

			return MapperFactory.UiElementDC_UiElement.MapToNewDCs(filteredElements);
		}

		//public virtual IList<UiElementDC> GetDefaultStatisticUiElements()
		//{
			
		//}
	}
}
