Пример #1
0
        public ConstraintsBroken getBrokenConstraints()
        {
            ConstraintsBroken constraintsBroken = new ConstraintsBroken();

            if (GeneralUtils.noConstraintsApply.Any(x => holidayRequest.StartDate >= x.StartDate &&
                                                    holidayRequest.EndDate <= x.EndDate))
            {
                return(constraintsBroken);
            }
            string userRole = user.Role.RoleName;

            if (isHolidayAllowanceExceeded())
            {
                constraintsBroken.ExceedsHolidayEntitlement = true;
            }
            if (userRole == GeneralUtils.HEAD_ROLE || userRole == GeneralUtils.DEPUTY_HEAD_ROLE)
            {
                if (isDeputyOrHeadOnHolidayAlready(userRole == GeneralUtils.DEPUTY_HEAD_ROLE
                    ? GeneralUtils.HEAD_ROLE : GeneralUtils.DEPUTY_HEAD_ROLE))
                {
                    constraintsBroken.HeadOrDeputy = true;
                }
            }
            if (userRole == GeneralUtils.SENIOR_ROLE || userRole == GeneralUtils.MANAGER_ROLE)
            {
                if (isNotMinimumNumberOfManagersOrSeniors(GeneralUtils.MINIMUM_NUMBER_MANAGERS_OR_SENIORS))
                {
                    constraintsBroken.ManagerOrSenior = true;
                }
            }
            double requiredPercentage = GeneralUtils.REQUIRED_PERCENTAGE_AT_LEAST_MAX;

            if (GeneralUtils.lessEmployeePercentageRequired.Any(x => holidayRequest.StartDate >= x.StartDate &&
                                                                holidayRequest.EndDate <= x.EndDate))
            {
                requiredPercentage = GeneralUtils.REQUIRED_PERCENTAGE_AT_LEAST_MIN;
            }
            if (areThereNotEnoughEmployeesWorking(requiredPercentage))
            {
                constraintsBroken.AtLeastPercentage = true;
            }
            return(constraintsBroken);
        }
Пример #2
0
 public static bool areAnyConstraintsBroken(ConstraintsBroken constraintsBroken)
 {
     return(constraintsBroken.AtLeastPercentage ||
            constraintsBroken.ExceedsHolidayEntitlement || constraintsBroken.ManagerOrSenior ||
            constraintsBroken.HeadOrDeputy);
 }