Exemplo n.º 1
0
        /// <summary>
        /// Method to add location items to the LocationList object.
        /// </summary>
        /// <param name="model"> The TrainingSessionModel with the Coordinate list.</param>
        public void FillLocationList(TrainingSessionModel model)
        {
            try
            {
                Location location;
                LocationList = new List <Location>();
                foreach (var item in model.Coordinates)
                {
                    location              = new Location();
                    location.ID_Route     = this.ID_Route;
                    location.Latitude     = item.lat;
                    location.Longitude    = item.lng;
                    location.isMilestone  = item.isMilestone;
                    location.isStartPoint = false;
                    location.isEndPoint   = false;
                    LocationList.Add(location);
                }

                LocationList[0].isStartPoint = true;
                LocationList.Last().isEndPoint = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemplo n.º 2
0
        public static OperationResponse <TrainingSessionModel> SessionToTransport(TrainingSession model)
        {
            TrainingSessionModel tsM  = new TrainingSessionModel();
            LocationModel        locM = new LocationModel();
            Route route = new Route(model.RouteID);

            tsM.Coordinates = new List <LocationModel>();

            var response = new OperationResponse <TrainingSessionModel>();

            tsM.Distance           = model.Distance;
            tsM.SessionID          = model.SessionID;
            tsM.SessionStatusID    = Utility.GetSessionStatusString(model.SessionStatusID);
            tsM.RouteID            = model.RouteID;
            tsM.RouteName          = route.RouteName;
            tsM.RelativeHumidity   = model.RelativeHumidity;
            tsM.Temperature        = model.Temperature;
            tsM.AverageBPM         = model.AverageBPM;
            tsM.StartTime          = model.StartTime;
            tsM.EndTime            = model.EndTime;
            tsM.BurntCalories      = model.BurntCalories;
            tsM.ClimateConditionID = Utility.GetClimateString(model.ClimateConditionID);
            tsM.UserID             = model.UserID;
            tsM.TrainingTypeID     = Utility.GetTrainingTyeString(model.TrainingTypeID);
            tsM.CityName           = Utility.GetCityString(route.CityID);
            tsM.CountryName        = Utility.GetCountryString(Utility.GetCountryFromCity(route.CityID));

            foreach (var item in route.LocationList)
            {
                locM.lat         = item.Latitude;
                locM.lng         = item.Longitude;
                locM.isMilestone = item.isMilestone;

                tsM.Coordinates.Add(locM);
            }

            return(response.Complete(tsM));
        }