public List <float> GetActivityInfoSums(int userId, DateTime now,
                                                PeriodTrainingDataStrategy periodStrategy,
                                                List <Types.TrainingType> activitylist)
        {
            var list = TrainingSessionRepository.GetAsQueryable <TrainingSession>().ToList()
                       .Where(
                d =>
                d.UserId == userId && periodStrategy.IsInLowerTimeBound(d))
                       .ToList();

            var timeSpans = periodStrategy.GetTimeSpans(now, periodStrategy.NumberOfRecords);

            var values = new List <float>();

            foreach (var timespan in timeSpans)
            {
                var allSessionInTimespan = AllSessionInTimespan(list, timespan);

                var activityCount = allSessionInTimespan.Sum(s => activitylist.Contains(s.TrainingEnumTypeId) ? 1 : 0);

                values.Add(activityCount);
            }

            return(values);
        }
        /// <summary>
        ///     calculates the sum of activities
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="now"></param>
        /// <param name="serviceDailyInfoSummaryData"></param>
        /// <param name="periodStrategy"></param>
        /// <returns></returns>
        private ServiceDailyInfoSummaryData FillTrainingDetailsDataSums(int userId, DateTime now,
                                                                        ServiceDailyInfoSummaryData
                                                                        serviceDailyInfoSummaryData,
                                                                        PeriodTrainingDataStrategy periodStrategy)
        {
            serviceDailyInfoSummaryData.TrainingData = new TrainingData
            {
                TrainningDataSummaries = TrainingDataService.GetActivityInfoSums(userId, now, periodStrategy,
                                                                                 new List <Types.TrainingType>
                {
                    Types.TrainingType.Endurance,
                    Types.TrainingType.Strength,
                    Types.TrainingType.Speed,
                    Types.TrainingType.Sport,
                    Types.TrainingType.Competition,
                    Types.TrainingType.Recovery,
                })
            };


            return(serviceDailyInfoSummaryData);
        }
        private List <TrainingDataTainingDetailsModel.TrainingDataValue> GetEffortSummary(DateTime now, PeriodTrainingDataStrategy periodTrainingDataStrategy,
                                                                                          NumericCalculationTypeStrategy numericCalculationTypeStrategy,
                                                                                          int numberOfRecordsToDisplay, IEnumerable <TrainingSession> sessions)
        {
            var timeSpans = periodTrainingDataStrategy.GetTimeSpans(now, numberOfRecordsToDisplay);
            var summaries = CollectEffortsFromSessions(timeSpans, numericCalculationTypeStrategy, sessions.ToList());

            return(summaries);
        }
        public List <TrainingDataTainingDetailsModel.TrainingDataValue> GetEffortSummary(int userId, DateTime now,
                                                                                         PeriodTrainingDataStrategy periodTrainingDataStrategy, NumericCalculationTypeStrategy numericCalculationTypeStrategy, int numberOfRecordsToDisplay)
        {
            var sessions = TrainingSessionRepository.GetAsQueryable <TrainingSession>().ToList()
                           .Where(d => d.UserId == userId && periodTrainingDataStrategy.IsInLowerTimeBound(d))
                           .ToList();

            return(GetEffortSummary(now, periodTrainingDataStrategy, numericCalculationTypeStrategy, numberOfRecordsToDisplay, sessions));
        }
        private Dictionary <Types.TrainingType, List <TrainingDataTainingDetailsModel.TrainingDataValue> > GetActivityInfoSummary(DateTime now, int numberOfRecordsToDisplay,
                                                                                                                                  PeriodTrainingDataStrategy periodTrainingDataStrategy,
                                                                                                                                  NumericCalculationTypeStrategy numericCalculationTypeStrategy,
                                                                                                                                  IEnumerable <Types.TrainingType> selectedActivityTypes, List <TrainingSession> sessions)
        {
            var activityTypesDic = new Dictionary <Types.TrainingType, List <TrainingDataTainingDetailsModel.TrainingDataValue> >();

            foreach (var type in selectedActivityTypes)
            {
                var timeSpans = periodTrainingDataStrategy.GetTimeSpans(now, numberOfRecordsToDisplay);

                Types.TrainingType type1 = type;
                var summaries            = CollectDataFromromSessions(
                    timeSpans,
                    sessions.ToList(),
                    s =>
                    numericCalculationTypeStrategy.CalculateTotalEffortForActivity(
                        periodTrainingDataStrategy.FilterLessThanHourActivities(s), type1));
                //summaries.Reverse();
                activityTypesDic.Add(type, summaries);
            }

            return(activityTypesDic);
        }
        public Dictionary <Types.TrainingType, List <TrainingDataTainingDetailsModel.TrainingDataValue> > GetActivityInfoSummary(int userId, DateTime now,
                                                                                                                                 int numberOfRecordsToDisplay,
                                                                                                                                 PeriodTrainingDataStrategy periodTrainingDataStrategy,
                                                                                                                                 NumericCalculationTypeStrategy numericCalculationTypeStrategy,
                                                                                                                                 IList <Types.TrainingType> selectedActivityTypes)
        {
            var sessions = TrainingSessionRepository.GetAsQueryable <TrainingSession>().ToList()
                           .Where(
                d => d.UserId == userId && periodTrainingDataStrategy.IsInLowerTimeBound(d)).ToList();


            return(GetActivityInfoSummary(now, numberOfRecordsToDisplay, periodTrainingDataStrategy, numericCalculationTypeStrategy, selectedActivityTypes, sessions));
        }
        private IList <TrainingDataTainingDetailsModel.TrainingDataValue> GetMeasurementInfoSummary(DateTime now, PeriodTrainingDataStrategy periodTrainingDataStrategy,
                                                                                                    NumericCalculationTypeStrategy numericCalculationTypeStrategy,
                                                                                                    int numberOfRecordsToDisplay, Func <TrainingSessionMeasurmentData, IList <DecimalData> > getter, List <TrainingSession> sessions)
        {
            numericCalculationTypeStrategy.MeasurmentInfoSelector = getter;

            sessions = FillTrainingSessionData(sessions);

            var timeSpans = periodTrainingDataStrategy.GetTimeSpans(now, numberOfRecordsToDisplay);
            IList <TrainingDataTainingDetailsModel.TrainingDataValue> summaries = CollectMeasurmentDataFromSessions(timeSpans,
                                                                                                                    numericCalculationTypeStrategy,
                                                                                                                    sessions
                                                                                                                    .ToList());

            return(summaries);
        }
        public IList <TrainingDataTainingDetailsModel.TrainingDataValue> GetMeasurementInfoSummary(int userId, DateTime now,
                                                                                                   PeriodTrainingDataStrategy periodTrainingDataStrategy,
                                                                                                   NumericCalculationTypeStrategy numericCalculationTypeStrategy,
                                                                                                   int numberOfRecordsToDisplay, Func <TrainingSessionMeasurmentData,
                                                                                                                                       IList <DecimalData> > getter)
        {
            var sessions = TrainingSessionRepository.GetAsQueryable <TrainingSession>().ToList()
                           .Where(d => d.UserId == userId && periodTrainingDataStrategy.IsInLowerTimeBound(d))
                           .ToList();

            return(GetMeasurementInfoSummary(now, periodTrainingDataStrategy, numericCalculationTypeStrategy, numberOfRecordsToDisplay, getter, sessions));
        }