Пример #1
0
        /// <summary>
        /// 模型数据改变
        /// </summary>
        /// <param name="obj"></param>
        private void dataChanged(RouteInfoModel RouteInfoModel)
        {
            getPageData(pageRepuestParams.PageIndex, pageRepuestParams.PageSize);
            var tmpModel = RouteInfoList.FirstOrDefault(a => a.Id == RouteInfoModel.Id);

            this.RouteInfo = RouteInfoList.FirstOrDefault();
        }
Пример #2
0
        private async Task <TrafficRouteInfoModel> GetRouteInfo(int routeNumber, char direction)
        {
            _response = await _client.GetAsync($"https://mu-kgt.ru/informing/wap/marsh/?m={routeNumber}&action=getMarshData");

            if (_response.IsSuccessStatusCode)
            {
                var resp = await _response.Content.ReadAsStringAsync();

                if (resp == "[]")
                {
                    return(null);
                }
                _rootElement = JsonConvert.DeserializeObject <RouteInfoModel>(resp);
                var routeInfo = new TrafficRouteInfoModel();

                if (direction == 't')
                {
                    routeInfo.ActiveBuses = _rootElement.TrafficAndBusStopInfo.DirectRoute
                                            .Where(x => x.Type == "ts")
                                            .Select(x => new ActiveBusModel
                    {
                        Model  = x.BusModel,
                        Number = x.BusNumber
                    });
                    routeInfo.BusStopList = _rootElement.TrafficAndBusStopInfo.DirectRoute
                                            .Where(x => x.Type == "stop")
                                            .Select(x => new BusStopModel
                    {
                        Name        = x.Title,
                        ArrivalTime = x.ArrivalTime == " " ? new TimeSpan(0, 0, 0) : TimeSpan.Parse(x.ArrivalTime)
                    });
                }
                else
                {
                    routeInfo.ActiveBuses = _rootElement.TrafficAndBusStopInfo.ReturnRoute
                                            .Where(x => x.Type == "ts")
                                            .Select(x => new ActiveBusModel
                    {
                        Model  = x.BusModel,
                        Number = x.BusNumber
                    });
                    routeInfo.BusStopList = _rootElement.TrafficAndBusStopInfo.ReturnRoute
                                            .Where(x => x.Type == "stop")
                                            .Select(x => new BusStopModel
                    {
                        Name        = x.Title,
                        ArrivalTime = x.ArrivalTime == " " ? new TimeSpan(0, 0, 0) : TimeSpan.Parse(x.ArrivalTime)
                    });
                }
                return(routeInfo);
            }
            return(null);
        }