/// <summary>
        ///
        /// </summary>
        /// <param name="measurmentData"></param>
        public void RemoveMeasurmentData(IList <TrainingSessionMeasurmentData> measurmentData)
        {
            GenericError error;

            measurmentData.ToList()
            .ForEach(md => TrainingSessionDataRepository.Remove(m => m.TrainingSessionId == md.TrainingSessionId, out error));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sessions"></param>
        /// <param name="trainingSession"></param>
        /// <param name="splitingSeconds"></param>
        public void SplitSessionAtSpecificTime(List <TrainingSession> sessions, TrainingSession trainingSession, DateTime splitingDateTime)
        {
            var measurmentData = GetSessionMeasurmentInfo(trainingSession.TrainingSessionId);

            var data = measurmentData.FirstOrDefault();

            TrainingSessionMeasurmentData session2Data = null;
            TrainingSessionMeasurmentData session1Data = null;

            if (data != null)
            {
                session1Data = CopyPartialMeasurmentsData(data, (m, t) => m.Where(x => x.Time >= splitingDateTime).ToList());
                session2Data = CopyPartialMeasurmentsData(data, (m, t) => m.Where(x => x.Time <= splitingDateTime).ToList());
                //session1Data = CopyPartialMeasurmentsData(data, (m, t) => m.Take(GetIndexForTime(t, splitingSeconds)).ToList());
                //session2Data = CopyPartialMeasurmentsData(data, (m, t) => m.Skip(GetIndexForTime(t, splitingSeconds)).ToList());
            }

            if (session1Data != null &&
                session2Data != null)
            {
                session1Data.TrainingSessionId = sessions[0].TrainingSessionId;
                session2Data.TrainingSessionId = sessions[1].TrainingSessionId;

                session1Data.UserId = trainingSession.UserId;
                session2Data.UserId = trainingSession.UserId;

                GenericError error;

                try
                {
                    TrainingSessionDataRepository.InsertEntity(out error, session1Data);
                    TrainingSessionDataRepository.InsertEntity(out error, session2Data);
                }
                catch (Exception e)
                {
                    error = new GenericError {
                        ErrorDesc = e.Message
                    };
                }

                if (error == null)
                {
                    TrainingSessionsRepository.InsertEntity(out error, sessions);

                    measurmentData.ToList().ForEach(md => TrainingSessionDataRepository.Remove(m => m.TrainingSessionId == md.TrainingSessionId, out error));
                    TrainingSessionsRepository.Remove(s => s.TrainingSessionId == trainingSession.TrainingSessionId, out error);
                }
            }
        }