Пример #1
0
  /*  public IEnumerator GetMenu(string restaurantId)
    {
        using (UnityWebRequest www = UnityWebRequest.Get(APIaddress + "/restaurant/getMenu?restaurantID=" + restaurantId))
        {
            yield return www.SendWebRequest();
            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
                UIViewManager.Instance.ErrorNotification(www.error);
                yield break;
            }
            else
            {
                string s = www.downloadHandler.text.Replace(@"\", "");
                JSONObject json = new JSONObject(s);
                DataContainers.Menu m = new DataContainers.Menu(json["menu"]);
                OnMenuLoaded?.Invoke(m);
            }
        }
    }*/
    public IEnumerator Register(string name, string email, string password)
    {
        WWWForm form = new WWWForm();
        form.AddField("name", name);
        form.AddField("email", email);
        form.AddField("password", password);
        using (UnityWebRequest www = UnityWebRequest.Post(APIaddress + "/user/register", form))
        {
            yield return www.SendWebRequest();
            if (www.isNetworkError || www.isHttpError)
            {

                JSONObject json = new JSONObject(www.downloadHandler.text);
                Debug.Log(json["message"].str);
                UIViewManager.Instance.ErrorNotification(json["message"].str);
            }
            else
            {
                JSONObject json = new JSONObject(www.downloadHandler.text);
                DataContainers.User u = new DataContainers.User(json["user"]);
                UIViewManager.Instance.SuccesNotification(json["message"].str);
                OnUserLogedIn?.Invoke(u);
            }
        }
    }
Пример #2
0
 public void setLoggedUser(DataContainers.User iUser)
 {
     user = iUser;
     UIViewManager.Instance.Username.text = iUser.name;
     UIViewManager.Instance.OpenPanel("CreateOrderView");
 }