Exemple #1
0
        public List <WeeklyAddition> GetAdditionPlanEntryEntries(int additionPlanId, LocationLevelGroupings locationGrouping
                                                                 , VehicleLevelGrouping vehicleGrouping)
        {
            var dbEntities = AdditionPlanEntryFilter.GetAdditionPlanEntries(DataContext, Parameters);

            dbEntities = from apmmv in dbEntities
                         where apmmv.AdditionPlanId == additionPlanId
                         select apmmv;


            var weeklyAdditions = ApplyLocationGroupingToWeeklyAdditions(dbEntities, locationGrouping);

            weeklyAdditions = ApplyVehicleGroupingOnWeeklyAdditions(weeklyAdditions, vehicleGrouping);


            var returned = weeklyAdditions.ToList();

            return(returned);
        }
Exemple #2
0
        private void PopulateAdditionTables(AdditionPlanDataAccess dataAccess, LocationLevelGroupings locationGrouping
                                            , VehicleLevelGrouping vehicleGrouping, int scenarioId, AutoGrid gridToUpdate, bool scenarioASelected)
        {
            var additionData = dataAccess.GetAdditionPlanEntryEntries(scenarioId, locationGrouping, vehicleGrouping);

            var additionPlan = dataAccess.GetAdditionPlan(scenarioId);

            var bottomLevelGrouping = locationGrouping == LocationLevelGroupings.Location &&
                                      vehicleGrouping == VehicleLevelGrouping.CarGroup;

            gridToUpdate.HideLastColumn = !bottomLevelGrouping;


            if (scenarioASelected)
            {
                rbAScenario.Text         = additionPlan.Name;
                lblMaxScenASelected.Text = additionPlan.MaxFleetScenarioName;
                lblMinScenASelected.Text = additionPlan.MinComSegScenarioName;
            }
            else
            {
                rbBScenario.Text         = additionPlan.Name;
                lblMaxScenBSelected.Text = additionPlan.MaxFleetScenarioName;
                lblMinScenBSelected.Text = additionPlan.MinComSegScenarioName;
            }

            var additionEntities = from ad in additionData
                                   select new AdditionEntity
            {
                Year         = ad.Year,
                IsoWeek      = ad.IsoWeek,
                CarGroupId   = ad.CarGroupId,
                LocationId   = ad.LocationId,
                CarGroup     = ad.CarGroup,
                Location     = ad.Location,
                Amount       = ad.Amount,
                Contribution = (double)ad.CpU
            };

            gridToUpdate.GridData = additionEntities.ToList();
            gridToUpdate.Visible  = true;
        }
Exemple #3
0
        private IQueryable <WeeklyAddition> ApplyLocationGroupingToWeeklyAdditions(IQueryable <AdditionPlanEntry> values, LocationLevelGroupings locationLevel)
        {
            IQueryable <WeeklyAddition> returned;

            switch (locationLevel)
            {
            case LocationLevelGroupings.Location:
                returned = from ape in values
                           select new WeeklyAddition
                {
                    IsoWeek    = ape.Week,
                    Year       = ape.Year,
                    Amount     = ape.Additions,
                    CpU        = ape.ContributionPerUnit,
                    CarGroupId = ape.CarGroupId,
                    Location   = ape.LOCATION.location1
                };
                break;

            case LocationLevelGroupings.LocationGroup:
                returned = from v in values
                           group v by new { v.Year, v.Week, v.CarGroupId, v.LOCATION.CMS_LOCATION_GROUP.cms_location_group1 }
                into groupedData
                    select new WeeklyAddition
                {
                    Year       = groupedData.Key.Year,
                    IsoWeek    = groupedData.Key.Week,
                    CarGroupId = groupedData.Key.CarGroupId,
                    Location   = groupedData.Key.cms_location_group1,
                    CpU        = groupedData.Sum(d => d.ContributionPerUnit),
                    Amount     = groupedData.Sum(d => d.Additions)
                };
                break;

            case LocationLevelGroupings.Pool:
                returned = from v in values
                           group v by new { v.Year, v.Week, v.CarGroupId, v.LOCATION.CMS_LOCATION_GROUP.CMS_POOL.cms_pool1 }
                into groupedData
                    select new WeeklyAddition
                {
                    Year       = groupedData.Key.Year,
                    IsoWeek    = groupedData.Key.Week,
                    CarGroupId = groupedData.Key.CarGroupId,
                    Location   = groupedData.Key.cms_pool1,
                    CpU        = groupedData.Sum(d => d.ContributionPerUnit),
                    Amount     = groupedData.Sum(d => d.Additions)
                };
                break;

            case LocationLevelGroupings.Country:
                returned = from v in values
                           group v by new { v.Year, v.Week, v.CarGroupId, v.LOCATION.CMS_LOCATION_GROUP.CMS_POOL.COUNTRy1.country_description }
                into groupedData
                    select new WeeklyAddition
                {
                    Year       = groupedData.Key.Year,
                    IsoWeek    = groupedData.Key.Week,
                    CarGroupId = groupedData.Key.CarGroupId,
                    Location   = groupedData.Key.country_description,
                    CpU        = groupedData.Sum(d => d.ContributionPerUnit),
                    Amount     = groupedData.Sum(d => d.Additions)
                };
                break;

            default:
                throw new ArgumentOutOfRangeException("locationLevel");
            }
            return(returned);
        }