public async void OnSearchButtonClicked() { Debug.Log(SearchInput.text); using (var httpClient = new HttpClient()) { Loading.ShowLoading("Searching..."); var reqPar = "q=" + SearchInput.text; using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://333f7sxvgg.execute-api.us-west-2.amazonaws.com/v1/search?" + reqPar)) { var response = await httpClient.SendAsync(request); Loading.CloseLoading(); Debug.Log(response); string body = await response.Content.ReadAsStringAsync(); Debug.Log(body); var stuff = (JObject)JsonConvert.DeserializeObject(body); var eventIds = (JArray)stuff["eventIds"]; var eventIdList = eventIds.ToObject <List <string> >(); Debug.Log(eventIdList); if (eventIdList.Count != 0) { searchResult.gameObject.SetActive(true); searchResult.ShowResult(eventIdList); } else { PopupManager.OpenPopup("", "No Result Found :("); } } } }
public async void OnDropButtonClicked() { Debug.Log("OnDropButtonClicked"); using (var httpClient = new HttpClient()) { //var reqPar = "numPeople=3&time=2021_4_9_12_15_30&restaurantId="+SelectedRestaurentID; Loading.ShowLoading("Dropping..."); var reqPar = "eid=" + eventId + "&userId=" + UserProfile.UserID; Debug.Log("reqPar: " + reqPar); using (var request = new HttpRequestMessage(new HttpMethod("POST"), "https://333f7sxvgg.execute-api.us-west-2.amazonaws.com/v1/drop?" + reqPar)) { var response = await httpClient.SendAsync(request); Debug.Log(response); string body = await response.Content.ReadAsStringAsync(); Debug.Log(body); Loading.CloseLoading(); var _result = (JObject)JsonConvert.DeserializeObject(body); if ((string)_result["statusCode"] == "200") { PopupManager.OpenPopup("Dropped", "Successfully drop from this event"); } else { PopupManager.OpenPopup("Sth Go Wrong", body); } OnEnable(); } } }
// Start is called before the first frame update public async void OnEnable() { var reqPar = "q=" + eventId; Debug.Log(reqPar); using (var httpClient = new HttpClient()) { using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://333f7sxvgg.execute-api.us-west-2.amazonaws.com/v1/detail?" + reqPar)) { Loading.ShowLoading("Loading Event Details..."); var response = await httpClient.SendAsync(request); Debug.Log(response); string body = await response.Content.ReadAsStringAsync(); Debug.Log(body); try { var stuff = (JObject)JsonConvert.DeserializeObject(body); string eventId = (string)stuff["eventIds"][0]["eventId"]; string userId = (string)stuff["eventIds"][0]["userId"]; string restaurantId = (string)stuff["eventIds"][0]["restaurantId"]; string time = (string)stuff["eventIds"][0]["time"]; string numPeople = (string)stuff["eventIds"][0]["numPeople"]; string joinedPeoleNum = (string)stuff["eventIds"][0]["joinedPeoleNum"]; var participants = (JArray)stuff["eventIds"][0]["participants"]; string userName = (string)stuff["eventIds"][0]["userName"]; string gender = (string)stuff["eventIds"][0]["gender"]; string timeText = time; try { System.DateTime dateTime = System.DateTime.Parse(time); timeText = string.Format("{0:D2}/{1:D2}/{2:D2} {3:D2}:{4:D2}:{5:D2}", dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second); } catch { } Participents.Clear(); if (participants != null) { Participents = participants.ToObject <List <string> >(); } PeopleJoinText.text = joinedPeoleNum + "/" + numPeople + " people joined"; TimeText.text = timeText; LoadRestaurentDetails(restaurantId); } catch (Exception exp) { Debug.Log(exp); } Loading.CloseLoading(); } } CheckEventJoinStatus(); }
IEnumerator WaitAndLoad() { Loading.ShowLoading("Logging In"); yield return(new WaitForSeconds(Random.Range(0.5f, 4.5f))); Loading.CloseLoading(); HomePage.SetActive(true); gameObject.SetActive(false); UnityEngine.Debug.Log("Login Success, UserID: " + UserProfile.UserID); }
public async void OnCreateButtonClicked() { Debug.Log(WhenInput.text); Debug.Log(HowManyInput.text); var _rName = RestaurentSelector.selectedText.text; string SelectedRestaurentID = ""; if (RestaurentNameToID.ContainsKey(_rName)) { SelectedRestaurentID = RestaurentNameToID[_rName]; } else { PopupManager.OpenPopup("", "Please pick a restaurant"); return; } Debug.Log(SelectedRestaurentID); using (var httpClient = new HttpClient()) { Loading.ShowLoading("Creating Event..."); //var reqPar = "numPeople=3&time=2021_4_9_12_15_30&restaurantId="+SelectedRestaurentID; var reqPar = "numPeople=" + HowManyInput.text + "&time=" + WhenInput.text + "&restaurantId=" + SelectedRestaurentID + "&userId=" + UserProfile.UserID; using (var request = new HttpRequestMessage(new HttpMethod("POST"), "https://333f7sxvgg.execute-api.us-west-2.amazonaws.com/v1/create?" + reqPar)) { var response = await httpClient.SendAsync(request); Debug.Log(response); string body = await response.Content.ReadAsStringAsync(); Debug.Log(body); Loading.CloseLoading(); var stuff = (JObject)JsonConvert.DeserializeObject(body); if ((string)stuff["statusCode"] == "200") { string evendID = (string)stuff["body"]; Debug.Log("Create Success, eventID: " + evendID); eventDetails.SetEventID(evendID); eventDetails.gameObject.SetActive(true); this.gameObject.SetActive(false); } else { PopupManager.OpenPopup("Sth Go Wrong", body); } } } }
public async void LoadRecommend() { using (var httpClient = new HttpClient()) { var reqPar = "userId=" + UserProfile.UserID + "&zipcode=10003"; using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://333f7sxvgg.execute-api.us-west-2.amazonaws.com/v1/recommendation?" + reqPar)) { Debug.Log("LoadRecommend, reqPar: " + reqPar); Loading.ShowLoading("Loading Recommendation..."); var response = await httpClient.SendAsync(request); Loading.CloseLoading(); Debug.Log(response); string body = await response.Content.ReadAsStringAsync(); Loading.CloseLoading(); Debug.Log(body); var stuff = (JObject)JsonConvert.DeserializeObject(body); var eventIds = (JArray)stuff["eventIds"]; if (eventIds == null) { return; } var eventIdList = eventIds.ToObject <List <string> >(); foreach (Transform child in RecommendsRoot.transform) { GameObject.Destroy(child.gameObject); } foreach (var _eventId in eventIdList) { var _cardInstance = (GameObject)Instantiate(EventCardTemplate); _cardInstance.transform.SetParent(RecommendsRoot); _cardInstance.transform.localScale = new Vector3(1, 1, 1); var _eventCard = _cardInstance.GetComponent <EventCard>(); _eventCard.eventID = _eventId; _eventCard.LoadEventDetails(); } } } }
/// <summary> /// Called from restaurentSearch /// </summary> /// <param name="v"></param> public async void OnEndEditCalled(string v) { Debug.Log(restaurentSearch.text); Loading.ShowLoading("Searching For Restaurant..."); using (var httpClient = new HttpClient()) { var reqPar = restaurentSearch.text; Debug.Log(reqPar); using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://ir5pgsnsfk.execute-api.us-west-2.amazonaws.com/v_0_0/search?zipcode=10027&q=" + reqPar)) { var response = await httpClient.SendAsync(request); Debug.Log(response); string body = await response.Content.ReadAsStringAsync(); Debug.Log(body); Loading.CloseLoading(); var stuff = (JArray)JsonConvert.DeserializeObject(body); RestaurentNameToID.Clear(); var _newDropDownList = new List <CustomDropdown.Item>(); foreach (var _rInfo in stuff) { Debug.Log(_rInfo["name"] + ", " + _rInfo["id"]); if (!RestaurentNameToID.ContainsKey((string)_rInfo["name"])) { RestaurentNameToID.Add((string)_rInfo["name"], (string)_rInfo["id"]); } _newDropDownList.Add(new CustomDropdown.Item() { itemIcon = RestaruentIcon, itemName = (string)_rInfo["name"] }); } RestaurentSelector.dropdownItems = _newDropDownList; RestaurentSelector.SetupDropdown(); } } }
public async void OnEnable() { using (var httpClient = new HttpClient()) { using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://333f7sxvgg.execute-api.us-west-2.amazonaws.com/v1/searchbyuid?q=" + UserProfile.UserID)) { Loading.ShowLoading("Loading My Events..."); var response = await httpClient.SendAsync(request); Debug.Log("MyEvents()"); Debug.Log(response); string body = await response.Content.ReadAsStringAsync(); Debug.Log(body); Loading.CloseLoading(); var eventIds = (JArray)JsonConvert.DeserializeObject(body); var eventIdList = eventIds.ToObject <List <string> >(); foreach (Transform child in RecommendsRoot.transform) { GameObject.Destroy(child.gameObject); } foreach (var _eventId in eventIdList) { var _cardInstance = (GameObject)Instantiate(EventCardTemplate); _cardInstance.transform.SetParent(RecommendsRoot); _cardInstance.transform.localScale = new Vector3(1, 1, 1); var _eventCard = _cardInstance.GetComponent <EventCard>(); _eventCard.eventID = _eventId; _eventCard.LoadEventDetails(); } } } }
//This will be called when this page is enabled private async void OnEnable() { var reqPar = "q=" + UserProfile.UserID; // uid1";//+ userID; Debug.Log(reqPar); using (var httpClient = new HttpClient()) { Loading.ShowLoading("Loading User Profile..."); Debug.Log(reqPar); using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://omx6f7pb2f.execute-api.us-west-2.amazonaws.com/user_v1/detail?" + reqPar)) { var response = await httpClient.SendAsync(request); Debug.Log(response); string body = await response.Content.ReadAsStringAsync(); Debug.Log(body); try { var stuff = (JObject)JsonConvert.DeserializeObject(body); var _name = stuff.GetValue("name"); if (_name != null) { NameInput.text = (string)_name; } var _email = stuff.GetValue("email"); if (_email != null) { EmailInput.text = (string)_email; } var _gender = stuff.GetValue("gender"); if (_gender != null) { int gender = (int)_gender; string gender_str = ""; if (gender == 0) { gender_str = "Male"; } else if (gender == 1) { gender_str = "Female"; } else if (gender == 2) { gender_str = "Non-binary"; } else { gender_str = "Unknown"; } GenderInput.text = gender_str; } else { GenderInput.text = "Unknown"; } var _events = stuff.GetValue("events"); if (_events != null) { } var _picture = stuff.GetValue("picture"); if (_picture != null) { StartCoroutine(LoadImage(Avatar, (string)_picture)); } } catch (Exception exp) { Debug.Log(exp); } } Loading.CloseLoading(); } }