Exemple #1
0
        public ActionResult GetSportSummary([System.Web.Http.FromUri] SportSummaryRequestInformation detail)
        {
            SportType sportType;

            try
            {
                sportType = EnumConversion.GetEnumFromDescription <SportType>(detail.Sport);
            }
            catch (ArgumentException)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SportSummaryDto details = DashboardSportSummary.Create(this.User.Identity.GetUserId(), sportType, detail.FromDateTime.Value, detail.ToDateTime.Value);


            return(PartialView("_sportSummary", details));
        }
Exemple #2
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);
        }