Example #1
0
        partial void BtnSaveChanges_TouchUpInside(UIButton sender)
        {
            //set pet attribute fields
            petAttribute.AttributeTitle       = tfAttributName.Text;
            petAttribute.AttributeDescription = tvAttributDescription.Text;
            petAttribute.PetAttributeType     = selectedType;

            //remove old attribute and add new one
            if (petAttributeID != -1)
            {
                ServerHelper.DeleteAttribut(Application.PetManager.SelectedPet.PetID, petAttributeID);
            }

            //send packet to server
            ServerPacketConfirmation serverPacketConfirmation = ServerHelper.AddAttribut(Application.PetManager.SelectedPet.PetID, petAttribute);

            if (serverPacketConfirmation.ActionSuccess)
            {
                this.NavigationController.PopViewController(true);
                return;
            }

            //chose right error message
            String errorMessage = string.Empty;

            switch (serverPacketConfirmation.NetworkError)
            {
            case NetworkError.SERVER_UNAVAILABLE:
                errorMessage = MSGBank.ERROR_NO_SERVER;
                break;

            default:
                errorMessage = $"Impossible de modifier les attributs";
                break;
            }
            //show error message
            BarHelper.DisplayErrorBar(uivMainView, MSGBank.ERROR_TITLE, errorMessage);
        }