using System;
using System.Collections.Generic;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.Plugins;
using BS.Shared.Core;
using BS.Shared.DataContracts;

namespace BeWo.SBBMainzReports.Calculations
{
	public class SbbMainzGroupDurationCalculator : GroupDurationCalculator
	{
		
	    public override GroupDurationDC CalculateGroupDuration(int personCount, int employeeCount, decimal totalDuration,
	        long[] costBearer2SupportConceptArray)
	    {
	        bool isJugendamt = true;
	        foreach (var oid in costBearer2SupportConceptArray)
	        {
	            var cb2sc = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(oid);

	            if (cb2sc.CostBearer.Organisation.Name != "Kreisjugendamt Landkreis Mainz-Bingen")
	            {
	                isJugendamt = false;
	            }
	        }
	        if (isJugendamt)
	        {
	            return new GroupDurationDC()
	            {
	                SingleDuration = totalDuration*employeeCount,
	                TotalDuration = totalDuration
	            };
	        }
	        return base.CalculateGroupDuration(personCount, employeeCount, totalDuration, costBearer2SupportConceptArray);
	    }
	}
}
