コード例 #1
0
        public RouteToPointOfInterestDTO StartUserTour(int userID, int tourID, double currentLatitude, double currentLongitude)
        {
            VerifyNoTourIsStarted(userID);
            _userTourRepo.StartUserTour(userID, tourID);
            UserTour activeTour = _userTourRepo.GetActiveTour(userID);
            POI      nextPOI    = _userPOIRepo.GetNextPOI(activeTour.Id);
            IEnumerable <CoordinateDTO> route = _geoLocationService.GetRoute(currentLatitude, currentLongitude,
                                                                             nextPOI.Coordinates.Latitude.Value,
                                                                             nextPOI.Coordinates.Longitude.Value);

            return(new RouteToPointOfInterestDTO {
                NextPOI = PointOfInterestDTO.Create().Compile()(nextPOI), RouteToNextPOI = route
            });
        }
コード例 #2
0
        private UserTour GetActiveTour(int userID)
        {
            UserTour userTour = _userTourRepo.GetActiveTour(userID);

            if (userTour == null)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.Forbidden)
                {
                    Content = new StringContent("User doesn't have a started tour")
                };
                throw new HttpResponseException(resp);
            }
            return(userTour);
        }