Пример #1
0
        public void PostUser(User User)
        {
            string url = "https://192.168.18.7:5001/api/Users";//my ipv4 ip for device and 10.0.2.2 for emulators

            string json =
                "{" +

                getQuotedString("username") + ":" + getQuotedString(User.username) + "," +
                getQuotedString("password") + ":" + getQuotedString(User.password) + "," +
                getQuotedString("email") + ":" + getQuotedString(User.email) + "," +

                getQuotedString("firstname") + ":" + getQuotedString(User.firstname) + "," +
                getQuotedString("lastname") + ":" + getQuotedString(User.lastname) + "," +
                getQuotedString("number") + ":" + getQuotedString(User.number) + "," +
                getQuotedString("address") + ":" + getQuotedString(User.address) + "," +
                getQuotedString("country") + ":" + getQuotedString(User.country) + "," +

                "}";

            if (APIConnect.Post(url, json))
            {
                Toast.MakeText(this, "User created successfully", ToastLength.Long).Show();
                Intent loginActivity = new Intent(this, typeof(LoginActivity));
                StartActivity(loginActivity);
            }
        }
Пример #2
0
        private bool checkexist(string uname)
        {
            bool        status   = true;
            string      url      = "https://192.168.18.7/api/Users";
            string      response = APIConnect.Get(url);
            List <User> users    = JsonConvert.DeserializeObject <List <User> >(response);

            foreach (User user in users)
            {
                if (user.username == uname)
                {
                    status = false;
                    break;
                }
            }

            return(status);
        }
Пример #3
0
        private bool checkLogin(string uname, string pass, out int id, out string name)
        {
            bool        status   = false;
            string      url      = "https://192.168.18.7/api/Users";
            string      response = APIConnect.Get(url);
            List <User> users    = JsonConvert.DeserializeObject <List <User> >(response);

            id   = 0;
            name = "";
            foreach (User user in users)
            {
                if (user.username == uname && user.password == pass)
                {
                    status = true;
                    id     = user.id;
                    name   = user.username;
                    break;
                }
            }

            return(status);
        }