コード例 #1
0
ファイル: RoadHelper.cs プロジェクト: Jos1k/Roads
        /// <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;
        }