예제 #1
0
        //##################################### handle post requests ##################################################

        //create user----------------------------------
        public void HandlePostUsers()
        {
            dynamic jasondata = JObject.Parse(body);

            string username = jasondata.Username;
            string password = jasondata.Password;
            bool   isadmin  = false;

            if (username == "admin")
            {
                isadmin = true;
            }
            if (Database.selectPlayerCreated(username) == 0)
            {
                if (Database.insertPlayer(username, password, isadmin))
                {
                    string data   = "\nPlayer was created\n";
                    string status = "200 Success";
                    string mime   = "text/plain";
                    ServerResponse(status, mime, data);
                }
                else
                {
                    string data   = "\nDatabase Error while trying to creat player\n";
                    string status = "200 Success";
                    string mime   = "text/plain";
                    ServerResponse(status, mime, data);
                }
            }
            else
            {
                string data   = "\nPlayer already exists\n";
                string status = "200 Success";
                string mime   = "text/plain";
                ServerResponse(status, mime, data);
            }
        }