Example #1
0
    public void RequestToSaveReward()
    {
        Debug.Log(CLASSNAME + "***** Request to save reward sent");
        //If reward exists, you are editing a current reward
        if (controller.CheckForExistingReward(rewardName.ToLower()))
        {
            //Resave the reward picture
            if (controller.RequestToSavePhoto(rewardName))
            {
                DisplayModal(ModalType.UPDATE, rewardName + MODAL_UPDATE_TEXT);
            }
            else
            {
                DisplayModal(ModalType.ERROR, MODAL_ERROR_TEXT);
            }
        }
        //else this is a new reward
        else
        {
            rewardName = wordFieldText.text;

            //If request to save to DB was successful
            if (controller.RequestToSaveReward(rewardName, rewardType, rewardUrl))
            {
                //If request to save photo was successful
                if (controller.RequestToSavePhoto(rewardName))
                {
                    DisplayModal(ModalType.SAVE, rewardName + MODAL_SAVE_TEXT);
                }
                else
                {
                    DisplayModal(ModalType.ERROR, MODAL_ERROR_TEXT);
                }
            }
            else
            {
                DisplayModal(ModalType.ERROR, MODAL_ERROR_TEXT);
            }
        }
    }
    public void RequestToSaveReward()
    {
        Debug.Log(CLASSNAME + "***** Request to save reward sent, reward name: " + rewardName);

        //If reward exists, you are editing a current reward
        if (controller.CheckForExistingReward(rewardName))
        {
            Debug.Log("edit pic = " + editPic + ", edit url = " + editUrl);
            //Resave the reward picture
            if ((editPic == true) && (editUrl == false))
            {
                Debug.Log("attempting to edit reward pic");
                controller.RequestToSavePhoto(rewardName);
                DisplayModal(ModalType.UPDATE, rewardName + MODAL_UPDATE_TEXT);
            }
            else if (editPic == true && (editUrl = true))
            {
                Debug.Log("attempting to edit reward pic and reward url");

                // controller.RequestToDeleteReward(rewardName);
                // controller.RequestToSaveReward(rewardName, rewardType, rewardUrl);
                controller.RequestToDeletePhoto(rewardName);
                controller.RequestToSavePhoto(rewardName);
                controller.RequestToSaveUrl(rewardName, rewardUrl);
                DisplayModal(ModalType.UPDATE, rewardName + MODAL_UPDATE_TEXT);
            }
            else if ((editPic == false) && (editUrl == true))
            {
                Debug.Log("attempting to edit reward url");

                controller.RequestToSaveUrl(rewardName, rewardUrl);
                DisplayModal(ModalType.UPDATE, rewardName + MODAL_UPDATE_TEXT);
            }
            else
            {
                Debug.Log("something went wring when attempting to edit");

                DisplayModal(ModalType.ERROR, MODAL_ERROR_TEXT);
            }
        }
        //else this is a new reward
        else
        {
            rewardName = wordFieldText.text;

            //If request to save to DB was successful
            if (controller.RequestToSaveReward(rewardName, rewardType, rewardUrl))
            {
                if (controller.IsThereACurrentPhoto())
                {
                    //If request to save photo was successful
                    if (controller.RequestToSavePhoto(rewardName))
                    {
                        DisplayModal(ModalType.SAVE, rewardName + MODAL_SAVE_TEXT);
                    }
                    else
                    {
                        DisplayModal(ModalType.ERROR, MODAL_ERROR_TEXT);
                    }
                }
                else
                {
                    DisplayModal(ModalType.SAVE, rewardName + MODAL_SAVE_TEXT);
                }
            }
            else
            {
                DisplayModal(ModalType.ERROR, MODAL_ERROR_TEXT);
            }
        }

        editUrl = false;
        editPic = false;
    }