Exemplo n.º 1
0
    public YipliPlayerInfo(DataSnapshot snapshot, string key)
    {
        try
        {
            if (snapshot != null)
            {
                Debug.Log("filling the YipliPlayerInfo from Snapshot.");
                playerId     = key.ToString();
                playerName   = snapshot.Child("name").Value?.ToString() ?? "";
                playerName   = char.ToUpper(playerName[0]) + playerName.Substring(1);
                playerWeight = snapshot.Child("weight").Value?.ToString() ?? "";
                playerHeight = snapshot.Child("height").Value?.ToString() ?? "";
                playerDob    = snapshot.Child("dob").Value?.ToString() ?? "";
                isMatTutDone = snapshot.Child("mat-tut-done").Value == null ? 0 : YipliHelper.StringToIntConvert(snapshot.Child("mat-tut-done").Value.ToString());

                //DOB is stored in the format "mm-dd-yyyy" in the backend
                Debug.Log("DOB recieved from backend : " + playerDob);
                if (playerDob == "")
                {
                    Debug.Log("Player age is null.");
                    playerAge = "";
                }
                else
                {
                    playerAge = CalculateAge(playerDob);
                    Debug.Log("Got Player age : " + playerAge);
                }

                profilePicUrl = snapshot.Child("profile-pic-url").Value?.ToString() ?? "";

                //If playername is not found, set PlayerId to null
                if (playerName == "")
                {
                    playerId = null;
                }

                SetProfilePicForPlayer(profilePicUrl);

                Debug.Log("Player Found with details :" + playerAge + " " + playerHeight + " " + playerId + " " + playerWeight + " " + playerName + " ProfilePicUrl:" + profilePicUrl);
            }
            else
            {
                Debug.Log("DataSnapshot is null. Can't create YipliPlayerInfo instance.");
                playerId = null;
            }
        }
        catch (Exception exp)
        {
            Debug.Log("Exception in creating YipliPlayerInfo object from DataSnapshot : " + exp.Message);
            playerId = null;
        }
    }
Exemplo n.º 2
0
    public static YipliPlayerInfo GetSavedPlayer()
    {
        Debug.Log("Getting saved player from device.");
        if (GetPropertyValue("player-id") != null && GetPropertyValue("player-name") != null)
        {
            return(new YipliPlayerInfo(GetPropertyValue("player-id"),
                                       GetPropertyValue("player-name"),
                                       GetPropertyValue("player-dob"),
                                       GetPropertyValue("player-height"),
                                       GetPropertyValue("player-weight"),
                                       GetPropertyValue("player-profilePicUrl"),
                                       YipliHelper.StringToIntConvert(GetPropertyValue("player-tutDone"))));
        }

        Debug.Log("Return null for GetSavedPlayer");
        return(null);
    }
Exemplo n.º 3
0
    public YipliThisUserTicketInfo(DataSnapshot snapshot)
    {
        try
        {
            if (snapshot != null)
            {
                Debug.Log("filling the Ticket info from Snapshot.");

                bleTest             = snapshot.Child("ble-test").Value?.ToString() ?? "";
                description         = snapshot.Child("description").Value?.ToString() ?? "";
                fileStorageLocation = snapshot.Child("file-storage-location").Value?.ToString() ?? "";
                timeCreated         = snapshot.Child("time-created").Value.ToString();
                usbTest             = snapshot.Child("usb-test").Value.ToString();
                ticketStatus        = YipliHelper.StringToIntConvert(snapshot.Child("ticket-status").Value.ToString());
            }
            else
            {
                Debug.Log("DataSnapshot is null. Can't create UserTicketInfo instance.");
                bleTest             = string.Empty;
                description         = string.Empty;
                fileStorageLocation = string.Empty;
                timeCreated         = string.Empty;
                usbTest             = string.Empty;
                ticketStatus        = 0;
            }
        }
        catch (Exception exp)
        {
            Debug.Log("Exception in creating UserTicketInfo object from DataSnapshot : " + exp.Message);
            bleTest             = string.Empty;
            description         = string.Empty;
            fileStorageLocation = string.Empty;
            timeCreated         = string.Empty;
            usbTest             = string.Empty;
            ticketStatus        = 0;
        }
    }