Example #1
0
        public void AnalyseTrail(ModelDataContext context, int userId, int trailId)
        {
            var rideIds = context.Rides
                          .Where(row => row.UserId == userId)
                          .OrderBy(row => row.StartUtc)
                          .Select(row => row.RideId)
                          .ToArray();

            var trail = context.Trails
                        .Where(row => row.TrailId == trailId)
                        .Select(row => new TrailAnalysis {
                TrailId   = row.TrailId,
                Locations = row.TrailLocations
                            .OrderBy(i => i.Order)
                            .Select(i => new LatLng {
                    Latitude  = i.Latitude,
                    Longitude = i.Longitude,
                })
                            .Cast <ILatLng>(),
            })
                        .SingleOrDefault();

            if (trail == null)
            {
                return;
            }

            foreach (int rideId in rideIds)
            {
                var ride = RideHelper.GetRideDto(context, rideId, userId);

                Analyse(context, userId, ride, new[] { trail });
            }
        }
Example #2
0
        public ActionResult <RideDto> Get(int id)
        {
            int userId = this.GetCurrentUserId();

            var ride = RideHelper.GetRideDto(context, id, userId);

            if (ride == null)
            {
                return(NotFound());
            }

            return(ride);
        }
Example #3
0
        public void Analyse(ModelDataContext context, int userId, int rideId)
        {
            var trails = context.Trails
                         .Select(row => new TrailAnalysis {
                TrailId   = row.TrailId,
                Locations = row.TrailLocations
                            .OrderBy(i => i.Order)
                            .Select(i => new LatLng {
                    Latitude  = i.Latitude,
                    Longitude = i.Longitude,
                })
                            .Cast <ILatLng>(),
            })
                         .ToList();

            Analyse(context, userId, RideHelper.GetRideDto(context, rideId, userId), trails);
        }