Пример #1
0
        public string GetATMovieTimeAsync(string location, string keyword)
        {
            LocalTimeService timeService = new LocalTimeService();
            var today = timeService.GetLocalDateTime(LocalTimeService.CHINA_STANDARD_TIME).Date;
            var str   = "";

            for (int count = 0; count < 3; count++)
            {
                var movieDate = today.AddDays(count).ToString("yyyy/MM/dd");
                var url       = $"http://www.ambassador.com.tw/ambassadorsite.webapi/api/Movies/GetShowtimeListForTheater/?theaterId={atMovieDict[location]}&showingDate={movieDate}";
                using (HttpClient client = new HttpClient())
                {
                    var response = client.GetStringAsync(url).Result;
                    var json     = JsonConvert.DeserializeObject <List <ATMovieModel> >(response).Where(x => x.Name.Contains(keyword)).ToList();
                    for (int i = 0; i < json.Count; i++)
                    {
                        str += json[i].PeriodShowtime[0].PlayingDate.ToString("yyyy/MM/dd") + "\r\n";
                        foreach (var item in json[i].PeriodShowtime)
                        {
                            str += item.AssistantName + "\r\n";
                            var timeArray = string.Join(" | ", item.Showtimes);
                            str += timeArray + "\r\n";
                        }
                        str += "============\r\n";
                    }
                }
            }


            return(str);
        }