public static ActivityDto CreateFromActivity(Activity fvActivity)
        {
            ActivityDto m = new ActivityDto();

            m.Id                = fvActivity.Id;
            m.Name              = fvActivity.Name;
            m.ActivityTypeId    = fvActivity.ActivityTypeId;
            m.DetailsDownloaded = true;
            m.Distance          = fvActivity.Distance.ToMiles();
            m.ElevationGain     = fvActivity.ElevationGain.ToFeet();
            m.Date              = fvActivity.StartDateLocal.ToShortDateString();
            m.MovingTime        = fvActivity.MovingTime.Value;
            m.Start             = fvActivity.Start;
            m.StartDateLocal    = fvActivity.StartDateLocal;
            m.SufferScore       = fvActivity.SufferScore.HasValue ? fvActivity.SufferScore.Value : 0;
            m.Calories          = fvActivity.Calories;
            m.HasMap            = fvActivity.StartLatitude != null ? true : false;
            m.IsRide            = fvActivity.ActivityType.IsRide;
            m.IsRun             = fvActivity.ActivityType.IsRun;
            m.IsSwim            = fvActivity.ActivityType.IsSwim;
            m.IsOther           = fvActivity.ActivityType.IsOther;

            m.HasPowerMeter = fvActivity.HasPowerMeter;
            m.TSS           = fvActivity.TSS.HasValue ? fvActivity.TSS.Value : 0;

            m.Athlete = AthleteDto.CreateFromAthlete(fvActivity.Athlete);
            m.Weight  = fvActivity.Weight;
            m.TSS     = fvActivity.TSS;

            return(m);
        }
Beispiel #2
0
        public static AthleteDto Create(IUnitOfWork uow, string userId)
        {
            Athlete a = uow.CRUDRepository.GetByUserId <Athlete>(userId, o => o.AthleteSetting).FirstOrDefault();

            if (a == null)
            {
                return(null);
            }

            AthleteDto dto = Mapper.Map <AthleteDto>(a);

            dto.SetupDateRange();
            return(dto);
        }
Beispiel #3
0
        public bool Populate()
        {
            _athlete = AthleteDto.Create(_uow, _userId);

            // athlete record
            if (_athlete == null)
            {
                return(false);
            }

            this.FirstName = _athlete.FirstName;
            this.LastName  = _athlete.LastName;
            this.Start     = _athlete.Start;
            this.End       = _athlete.End;

            ApplicationDb context = new ApplicationDb();

            PeaksDtoRepository peaksRepo = new PeaksDtoRepository(context);

            _timesRepo = new RunningTimesDtoRepository(context);
            ActivityDtoRepository    activityRepo = new ActivityDtoRepository(context);
            WeightByDayDtoRepository weightRepo   = new WeightByDayDtoRepository(context);

            // get a list of activities which will be used to extract various summary information details.
            _summaryActivities = activityRepo.GetSportSummaryQuery(_userId, SportType.All, _athlete.Start, _athlete.End).ToList();

            PowerPeaks     = peaksRepo.GetPeaks(_userId, PeakStreamType.Power);
            RunningTime    = _timesRepo.GetBestTimes(_userId);
            CurrentWeight  = weightRepo.GetMetricDetails(_userId, MetricType.Weight, 1)[0];
            RecentActivity = activityRepo.GetRecentActivity(_summaryActivities, 7);

            RunSummary        = DashboardSportSummary.Create(_userId, SportType.Run, _athlete.Start, _athlete.End, _summaryActivities);
            BikeSummary       = DashboardSportSummary.Create(_userId, SportType.Ride, _athlete.Start, _athlete.End, _summaryActivities);
            SwimSummary       = DashboardSportSummary.Create(_userId, SportType.Swim, _athlete.Start, _athlete.End, _summaryActivities);
            OtherSportSummary = DashboardSportSummary.Create(_userId, SportType.Other, _athlete.Start, _athlete.End, _summaryActivities);
            AllSportSummary   = DashboardSportSummary.Create(_userId, SportType.All, _athlete.Start, _athlete.End, _summaryActivities);

            return(true);
        }