Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FindRoadModel"/> class.
 /// </summary>
 public FindRoadModel()
 {
     SearchResult = new ListRoadsViewModel();
     OriginCityNodeId = -1;
     DestinationCityNodeId = -1;
 }
Beispiel #2
0
        /// <summary>
        /// Gets the search result for.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns>The <see cref="ListRoadsViewModel"/>.</returns>
        public static ListRoadsViewModel GetSearchResultFor(IRoadsService client, FindRoadModel model, bool isRouteValidation)
        {
            var responce = new ListRoadsViewModel();
            string currentLang = CultureHelper.GetNeutralCulture(CultureHelper.GetCurrentCulture());
                var data = client.GetRoadsFor(model.OriginCityNodeId, model.DestinationCityNodeId,
                    model.SearchResult.PageNumber, currentLang, isRouteValidation );

                responce.ActualRange = data.ActualRange;

                responce.NumberOfFound = data.Count;

                responce.RecordsPerPage = data.RecordsPerPage;

                responce.PageNumber = model.SearchResult.PageNumber;

                responce.RoadsList =
                    data.Treks.Select(s => new RoadSearchingResultViewModel
                    {
                        OriginCityName = s.OriginCityNodeName,
                        DestinationCityName = s.DesinationCityNodeName,
                        RouteHash = s.Hash,
                        Trek = s.Track,
                        InterimCities = s.Track.Split('-').Count() - 2,
                        FeedbacksCount = s.FeedbackCount

                    }).ToList();

            return responce;
        }