private void GetUserEvent() { System.Diagnostics.Debug.WriteLine("GetUserEvent"); var client = new RestClient("https://www.happybi.com.tw/api/myevent"); //var client = new RestClient("http://127.0.0.1:8000/api/myevent"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Accept", "application/json"); request.AddParameter("id", App.CurrentUser.User_id); request.AddParameter("token", App.CurrentUser.Token.ToString()); IRestResponse response = client.Execute(request); if (response.Content != null) { if (response.Content != null) { System.Diagnostics.Debug.WriteLine(response.Content); List <Event> _events = JsonConvert.DeserializeObject <List <Event> >(response.Content); My_events_id.Clear(); foreach (var eve in _events) { My_events_id.Add(eve.id); } } } }
private void GetEvents() { var client = new RestClient($"https://www.happybi.com.tw/api/getEvents?category={SelectCategory.id}&district={SelectDistrict.id}"); var request = new RestRequest(Method.GET); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Accept", "application/json"); IRestResponse response = client.Execute(request); if (response.Content != null) { if (response.Content != null) { List <Event> _events = JsonConvert.DeserializeObject <List <Event> >(response.Content); Events.Clear(); foreach (var eve in _events) { int ind = My_events_id.IndexOf(eve.id); if (ind < 0) { eve.Participate = false; } else { eve.Participate = true; } eve.district_name = DistrictDictionary[eve.district_id]; eve.category_name = CategoryDictionary[eve.category_id]; Events.Add(eve); } temp_events = Events; } } }