Example #1
0
 public ICollection <DayWeatherData> GetWeatherDataFromWeight(StationWeight stationWeight)
 {
     return(this.weatherData
            .Where(x => x.Station.Id == stationWeight.Station.Id)
            .Where(x => x.Date >= stationWeight.From && x.Date <= stationWeight.To)
            .ToList());
 }
Example #2
0
        public ICollection <StationWeight> GetStationWeightsForPeriod(DateTime start, DateTime end, ICollection <StationAvailabilityPeriod> availPeriods)
        {
            var result = new List <StationWeight>();

            var groupedStationWeights = this.stationWeights
                                        .Where(x => availabilityPeriods.Any(y => y.Station.Name == x.Station.Name))
                                        .Where(x => x.From >= start && x.To <= end)
                                        .GroupBy(x => x.Station.Name);

            foreach (var stationWeightGroup in groupedStationWeights)
            {
                StationWeight weightToAdd = stationWeightGroup
                                            .OrderByDescending(x => x.AddedOn)
                                            .FirstOrDefault();

                if (weightToAdd != null)
                {
                    result.Add(weightToAdd);
                }
            }

            return(result);
        }