/// <summary>
        ///
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="data"></param>
        /// <param name="auxiliary"></param>
        public override bool IsSatisfied(object data, object auxiliary = null)
        {
            ResourceConstraintData cData = (ResourceConstraintData)data;

            bool isSatisfied       = true;
            bool peopleMatch       = false;
            bool timeMatchComplete = false;

            if (ForPerson != null && ForTimeInterval != null)
            {
                peopleMatch       = ConstraintCheckHelpers.PeopleMatch(ForPerson, cData.PersonsInSchedule);
                timeMatchComplete = ConstraintCheckHelpers.TimeMatchComplete(ForTimeInterval.StartTime.Instant, ForTimeInterval.EndTime.Instant, (DateTime)cData.TimePeriodInSchedule.StartTime.Instant, (DateTime)cData.TimePeriodInSchedule.EndTime.Instant);

                if (peopleMatch && timeMatchComplete)
                {
                    isSatisfied     = false;
                    MessageTemplate = "The resource is blocked for the choosen time period and selected people.";
                }
            }
            else if (ForPerson != null)
            {
                peopleMatch = ConstraintCheckHelpers.PeopleMatch(ForPerson, cData.PersonsInSchedule);
                if (peopleMatch)
                {
                    isSatisfied     = false;
                    MessageTemplate = "The resource is blocked selected people.";
                }
            }
            else if (ForTimeInterval != null)
            {
                timeMatchComplete = ConstraintCheckHelpers.TimeMatchComplete(ForTimeInterval.StartTime.Instant, ForTimeInterval.EndTime.Instant, (DateTime)cData.TimePeriodInSchedule.StartTime.Instant, (DateTime)cData.TimePeriodInSchedule.EndTime.Instant);
                if (timeMatchComplete)
                {
                    isSatisfied     = false;
                    MessageTemplate = "The resource is blocked for the choosen time period";
                }
            }

            if (ForPeriodicTimeInterval != null)
            {
                PeriodicTimeHelper pHelper   = new PeriodicTimeHelper();
                List <DateTime>    tempDates = pHelper.PeriodicTimeMatch(ForPeriodicTimeInterval, ForTimeInterval, (DateTime)cData.TimePeriodInSchedule.StartTime.Instant, (DateTime)cData.TimePeriodInSchedule.EndTime.Instant);
                if (tempDates.Count() > 0)
                {
                    isSatisfied = false;
                    string m = "";
                    foreach (DateTime d in tempDates)
                    {
                        m += d.ToString() + "\r\n";
                    }
                    MessageTemplate = String.Format("The resource is blocked on the followings day(s): {0}", m);
                }
            }


            return(isSatisfied);
        }
        /// <summary>
        ///
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="data"></param>
        /// <param name="auxiliary"></param>
        public override bool IsSatisfied(object data, object auxiliary = null)
        {
            bool isSatisfied             = true;
            bool peopleMatch             = false;
            bool timeMatchComplete       = false;
            ResourceConstraintData cData = (ResourceConstraintData)data;

            List <long> personInConstraint = new List <long>();

            //Case 1: Person AND Time Period restriction
            if ((ForPerson != null || AllUsers) && (ForTimeInterval != null || ForEver))
            {
                if (ForPerson != null)
                {
                    peopleMatch = ConstraintCheckHelpers.PeopleMatch(ForPerson, cData.PersonsInSchedule);
                }

                if (ForTimeInterval != null)
                {
                    timeMatchComplete = ConstraintCheckHelpers.TimeMatchComplete(ForTimeInterval.StartTime.Instant, ForTimeInterval.EndTime.Instant, (DateTime)cData.TimePeriodInSchedule.StartTime.Instant, (DateTime)cData.TimePeriodInSchedule.EndTime.Instant);
                }


                if ((peopleMatch && timeMatchComplete) || (peopleMatch && ForEver) || (timeMatchComplete && AllUsers) || (ForEver && AllUsers))
                {
                    switch (ComparisonOperator)
                    {
                    case ComparisonOperator.Equals:
                    {
                        if (Quantity != cData.QuantityInSchedule)
                        {
                            isSatisfied     = false;
                            MessageTemplate = String.Format("You must book a Quantity {0} {1}.", ComparisonOperator, Quantity);
                        }
                        break;
                    }
                    }
                }
            }
            else if (ForPerson != null || AllUsers)
            {
                if (ForPerson != null)
                {
                    peopleMatch = ConstraintCheckHelpers.PeopleMatch(ForPerson, cData.PersonsInSchedule);
                }

                if (peopleMatch || AllUsers)
                {
                    switch (ComparisonOperator)
                    {
                    case ComparisonOperator.Equals:
                    {
                        if (Quantity != cData.QuantityInSchedule)
                        {
                            isSatisfied     = false;
                            MessageTemplate = String.Format("You must book a Quantity {0} {1}.", ComparisonOperator, Quantity);
                        }
                        break;
                    }
                    }
                }
            }
            else if (ForTimeInterval != null || ForEver)
            {
                if (ForTimeInterval != null)
                {
                    timeMatchComplete = ConstraintCheckHelpers.TimeMatchComplete(ForTimeInterval.StartTime.Instant, ForTimeInterval.EndTime.Instant, (DateTime)cData.TimePeriodInSchedule.StartTime.Instant, (DateTime)cData.TimePeriodInSchedule.EndTime.Instant);
                }

                if (timeMatchComplete || ForEver)
                {
                    switch (ComparisonOperator)
                    {
                    case ComparisonOperator.Equals:
                    {
                        if (Quantity != cData.QuantityInSchedule)
                        {
                            isSatisfied     = false;
                            MessageTemplate = String.Format("You must book a Quantity {0} {1}.", ComparisonOperator, Quantity);
                        }
                        break;
                    }
                    }
                }
            }
            //else
            //{
            //    switch (ComparisonOperator)
            //    {
            //        case ComparisonOperator.Equals:
            //            {
            //                if (Quantity != cData.Quantity)
            //                {
            //                    isSatisfied = false;
            //                    MessageTemplate = String.Format("You must book a Quantity {0} {1}.", ComparisonOperator, Quantity);
            //                }
            //                break;
            //            }
            //    }
            //}

            return(isSatisfied);
        }
        /// <summary>
        ///
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="data"></param>
        /// <param name="auxiliary"></param>
        public override bool IsSatisfied(object data, object auxiliary = null)
        {
            bool isSatisfied             = true;
            ResourceConstraintData cData = (ResourceConstraintData)data;

            int countdependentQuantity = 0;

            var dependentResources = cData.SchedulesInEvent.Where(a => a.Resource.Id == ForResource.Id).ToList();

            if (dependentResources.Count() > 0)
            {
                var q = dependentResources.Where(a => a.Quantity > 1).Select(a => a.Quantity).ToList().Sum();
                countdependentQuantity = dependentResources.Count() * q;
            }

            //check if the time period for the resource in this schedule match with the time period from the depented resources
            foreach (Schedule s in cData.SchedulesInEvent)
            {
                if (!ConstraintCheckHelpers.TimeMatchComplete(s.StartDate, s.EndDate, cData.TimePeriodInSchedule.StartTime.Instant.Value, cData.TimePeriodInSchedule.EndTime.Instant.Value))
                {
                    isSatisfied      = false;
                    MessageTemplate += String.Format("The booking time period for the resource {0} must fit with this time period. \r\n", s.Resource.Name);
                }
            }

            if (Quantity == 1)
            {
                if (dependentResources.Count() == 0)
                {
                    isSatisfied = false;

                    //if you book more then 1 of the resouce which have a Dependency then you need also more depend resources
                    if (cData.QuantityInSchedule > 1)
                    {
                        MessageTemplate += String.Format("If you book this resource you have to book additionally this resource {0} {1} times.", ForResource.Name, cData.QuantityInSchedule);
                    }
                    else
                    {
                        MessageTemplate += String.Format("If you book this resource you have to book additionally this resource {0} one times.", ForResource.Name);
                    }
                }
                else if (countdependentQuantity != cData.QuantityInSchedule)
                {
                    isSatisfied      = false;
                    MessageTemplate += String.Format("If you book this resource with a Quanity of {2} you have to book additionally this resource {0} {1} times.", ForResource.Name, cData.QuantityInSchedule, Quantity);
                }
            }
            else
            {
                //Constraint quantity multiply in schedule quantity from the source resource result in the quantiry that you need from the dependent resource
                int neededQuantity = Quantity * cData.QuantityInSchedule;

                if (dependentResources.Count() > 0)
                {
                    switch (QuantityComparisonOperator)
                    {
                    case ComparisonOperator.Equals:
                    {
                        if (neededQuantity != countdependentQuantity)
                        {
                            isSatisfied      = false;
                            MessageTemplate += String.Format("If you book this resource {2} times you have to book additionally this resource {0} with a Quantity of {1}", ForResource.Name, neededQuantity, cData.QuantityInSchedule);
                        }
                        break;
                    }
                    }
                }
                else
                {
                    isSatisfied     = false;
                    MessageTemplate = String.Format("If you book this resource {2} times you have to book additionally this resource {0} with a Quantity of {1}", ForResource.Name, neededQuantity, cData.QuantityInSchedule);
                }
            }

            return(isSatisfied);
        }