Exemplo n.º 1
0
    public override string init(string json)
    {
        string loggedUserID;
        recieveloginRquest request = JsonMapper.ToObject<recieveloginRquest>(json);

        mysql sql = new mysql();

        MySqlDataReader result = sql.query("SELECT id FROM login WHERE username='******' AND password='******'");

        int findOneResult = 0;
        while (result.Read())
        {
            findOneResult++;
            loggedUserID = result["id"].ToString();
        }

        recieveLoginResponse response = new recieveLoginResponse();

        if (findOneResult == 1)
        {
            response.response = 1;
            response.message = "Succeful login attempt by '" + request.username + "'";
            // selectCharacterList(1);
        }
        else if(findOneResult > 1)
        {
            response.response = 0;
            response.message = "More than 1 account are found with this credential. Contact the admin to assistence.";
        }
        else
        {
            response.response = 0;
            response.message = "Failed login attempt by ==> '" + request.username + "'";
        }

        //close Data Reader
        sql.CloseConnection();

        return JsonMapper.ToJson(response);
    }