Ejemplo n.º 1
0
        private AnnualPlanHuntEquipmentTypeModel GetAnnualPlanHuntEquipmentTypeModel(HuntEquipmentType huntEquipmentType, IList <HuntEquipmentPlanDto> previousMarketingYearHuntEquipmentPlans, IList <HuntEquipmentPlanDto> currentMarketingYearHuntEquipmentPlans)
        {
            var annualPlanHuntEquipmentTypeModel = new AnnualPlanHuntEquipmentTypeModel
            {
                HuntEquipmentType     = huntEquipmentType,
                HuntEquipmentTypeName = TypeName.GetHuntEquipmentTypeName((int)huntEquipmentType),
                PreviousPlan          = previousMarketingYearHuntEquipmentPlans.FirstOrDefault(x => x.Type == (int)huntEquipmentType)?.Count ?? 0
            };

            switch (annualPlanHuntEquipmentTypeModel.HuntEquipmentType)
            {
            case HuntEquipmentType.Pasture:
                IList <PastureDto> currentStatePastures = _pastureDao.GetActiveByMarketingYear(CurrentMarketingYearId);
                IList <PastureDto> previousMarketingYearPasturesState = _pastureDao.GetActiveByMarketingYear(PreviousMarketingYearId);
                annualPlanHuntEquipmentTypeModel.CurrentState = currentStatePastures.Count;
                annualPlanHuntEquipmentTypeModel.Execution    = currentStatePastures.Count - previousMarketingYearPasturesState.Count;
                annualPlanHuntEquipmentTypeModel.FutureState  = currentStatePastures.Count + currentMarketingYearHuntEquipmentPlans.FirstOrDefault(x => x.Type == (int)huntEquipmentType)?.Count ?? 0;
                break;

            case HuntEquipmentType.Pulpit:
                IList <PulpitDto> currentStatePulpits = _pulpitDao.GetActiveByMarketingYear(CurrentMarketingYearId);
                IList <PulpitDto> previousMarketingYearPulpitsState = _pulpitDao.GetActiveByMarketingYear(PreviousMarketingYearId);
                annualPlanHuntEquipmentTypeModel.CurrentState = currentStatePulpits.Count;
                annualPlanHuntEquipmentTypeModel.Execution    = currentStatePulpits.Count - previousMarketingYearPulpitsState.Count;
                annualPlanHuntEquipmentTypeModel.FutureState  = currentStatePulpits.Count + currentMarketingYearHuntEquipmentPlans.FirstOrDefault(x => x.Type == (int)huntEquipmentType)?.Count ?? 0;
                break;

            case HuntEquipmentType.DeerLicker:
                IList <DeerLickerDto> currentStateDeerLickers = _deerLickerDao.GetByMarketingYear(CurrentMarketingYearId);
                IList <DeerLickerDto> previousMarketingYearDeerLickersState = _deerLickerDao.GetByMarketingYear(PreviousMarketingYearId);
                annualPlanHuntEquipmentTypeModel.CurrentState = currentStateDeerLickers.Sum(x => x.Count);
                annualPlanHuntEquipmentTypeModel.Execution    = currentStateDeerLickers.Sum(x => x.Count) - previousMarketingYearDeerLickersState.Sum(x => x.Count);
                annualPlanHuntEquipmentTypeModel.FutureState  = currentStateDeerLickers.Sum(x => x.Count) + currentMarketingYearHuntEquipmentPlans.FirstOrDefault(x => x.Type == (int)huntEquipmentType)?.Count ?? 0;
                break;

            case HuntEquipmentType.WateringPlace:
                IList <WateringPlaceDto> currentStateWateringPlaces = _wateringPlaceDao.GetActiveByMarketingYear(CurrentMarketingYearId);
                IList <WateringPlaceDto> previousMarketingYearWateringPlacesState = _wateringPlaceDao.GetActiveByMarketingYear(PreviousMarketingYearId);
                annualPlanHuntEquipmentTypeModel.CurrentState = currentStateWateringPlaces.Count;
                annualPlanHuntEquipmentTypeModel.Execution    = currentStateWateringPlaces.Count - previousMarketingYearWateringPlacesState.Count;
                annualPlanHuntEquipmentTypeModel.FutureState  = currentStateWateringPlaces.Count + currentMarketingYearHuntEquipmentPlans.FirstOrDefault(x => x.Type == (int)huntEquipmentType)?.Count ?? 0;
                break;

            case HuntEquipmentType.Aviary:
            case HuntEquipmentType.Farm:
            default:
                break;
            }

            return(annualPlanHuntEquipmentTypeModel);
        }