コード例 #1
0
ファイル: DataAccess.cs プロジェクト: hugohernani/eugenio
    bool createUpdateUserPlays(List <User.UserPlays> userPlaysLoadedList)
    {
        string targetUri = serverUriPath + userAccessUriPath;

        targetUri += ("saveScores/");

        int  qntSavedInDB = 0;
        bool success      = false;

        foreach (User.UserPlays up in userPlaysLoadedList)
        {
            Dictionary <string, string> userPlaysDict = new Dictionary <string, string> ();

            userPlaysDict.Add("user", up.UserId.ToString());
            userPlaysDict.Add("game", up.GameId.ToString());
            userPlaysDict.Add("score", up.Score.ToString());

            bool result = POSTConfirmation(targetUri, userPlaysDict);

            if (result)
            {
                qntSavedInDB++;
                Debug.Log("UserPlays tuple created/updated in database");
            }
            else
            {
                saveLoad.AddUserPlays(up);
                Debug.Log("UserPlays saved in file");
            }
        }

        if (qntSavedInDB != 0 && qntSavedInDB == userPlaysLoadedList.Count)
        {
            success = true;
        }

        if (saveLoad != null)
        {
            saveLoad.SaveUserDoes();
        }

        return(success);
    }