Exemplo n.º 1
0
        async private void AddPetAction()
        {
            var serverConnect = new ServerConnect();
            var petObject     = new Pet
            {
                PetID    = StringOperations.GenerateID(),
                UserID   = MainApp.Session.UserID,
                PetName  = Pet_Name,
                PetBreed = Pet_Breed,
                PetDesc  = Pet_Desc
            };

            IsBusy = true;
            ServerResponseObject response = await serverConnect.ConnectApi(petObject, Keys.Aws_Resource_SavePet);

            IsBusy = false;

            if (response.status == ServerReplyStatus.Success)
            {
                await MainApp.MainPage.DisplayAlert("Attention!", "Pet data saved successfully!", "Ok");
            }
            else if (response.status == ServerReplyStatus.Fail)
            {
                await MainApp.MainPage.DisplayAlert("Attention!", "Error saving pet data!", "Ok");
            }
            else if (response.status == ServerReplyStatus.Unknown)
            {
                await MainApp.MainPage.DisplayAlert("Attention!", $"Error saving pet data!:{response.error}", "Ok");
            }
        }
Exemplo n.º 2
0
        private async void LoadItemsServer()
        {
            var _object = new GenericID_Action
            {
                UserID = MainApp.Session.UserID,// ID will be extracted from Auth pool in aws
            };

            var serverConnect = new ServerConnect();


            IsBusy = true;
            var response = await serverConnect.ConnectApi(_object, Keys.Aws_Resource_PetsLoad);

            IsBusy = false;

            if (response.status != ServerReplyStatus.Success)
            {
                await MainApp.MainPage.DisplayAlert("Error!", "Error loading pets data!", "Ok");

                return;
            }

            Debug.WriteLine("list data are:");
            Debug.WriteLine(response.data);

            var result = JsonConvert.DeserializeObject <BaseReturnPets>(response.data);

            ItemsList = new ObservableCollection <Pet>(result.Pets);
        }