Example #1
0
        async void OnSaveButtonClicked(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(entryID.Text))
            {
                await App.FarmDatabase.SaveFarmAsync(new Farm
                {
                    ID          = int.Parse(entryID.Text),
                    Name        = entryName.Text,
                    Description = entryDescription.Text,
                    Street      = entryStreet.Text,
                    Locality    = entryLocality.Text,
                    Country     = entryCountry.Text
                });
            }
            else
            {
                await App.FarmDatabase.SaveFarmAsync(new Farm
                {
                    Name        = entryName.Text,
                    Description = entryDescription.Text,
                    Street      = entryStreet.Text,
                    Locality    = entryLocality.Text,
                    Country     = entryCountry.Text
                });
            }
            await Navigation.PopModalAsync();

            instance = null;
        }
Example #2
0
        async void OnDeleteButtonClicked(object sender, EventArgs e)
        {
            Farm farm = (Farm)BindingContext;
            await App.FarmDatabase.DeleteFarmAsync(farm);

            await Navigation.PopModalAsync();

            instance = null;
        }
Example #3
0
 private async void OnButtonAddClicked(object sender, EventArgs e)
 {
     if (FarmDetailPage.instance == null)
     {
         var page = new NavigationPage(FarmDetailPage.GetInstance());
         page.BarBackgroundColor = Color.FromHex("0078D7");
         MessagingCenter.Send(GenerateNewAgriFarmWithId(), "AddItem");
         await Navigation.PushModalAsync(page);
     }
 }
 private async void OnButtonAddClicked(object sender, EventArgs e)
 {
     if (FarmDetailPage.instance == null)
     {
         //FarmDetailPage.buttonDeleteVisibility = false;
         var page = new NavigationPage(FarmDetailPage.GetInstance());
         page.BarBackgroundColor = Color.FromHex("0078D7");
         await Navigation.PushModalAsync(page);
     }
 }
Example #5
0
 async void OnItemEditClicked(object sender, EventArgs e)
 {
     if (FarmDetailPage.instance == null && listViewFarm.SelectedItem != null)
     {
         FarmDetailPage.buttonDeleteVisibility = true;
         var page = new NavigationPage(FarmDetailPage.GetInstance());
         page.BarBackgroundColor = Color.FromHex("0078D7");
         page.BindingContext     = App.SelectedAgriFarm;
         await Navigation.PushModalAsync(page);
     }
 }
        public static FarmDetailPage GetInstance()
        {
            lock (_lock)
            {
                if (instance == null)
                {
                    instance = new FarmDetailPage();
                }

                return(instance);
            }
        }
        async void OnSaveButtonClicked(object sender, EventArgs e)
        {
            string dateTime = DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ss.ff'Z'");

            if (string.IsNullOrWhiteSpace(entryID.Text))
            {
                await manager.Add(new AgriFarm
                {
                    id      = id,
                    type    = "AgriFarm",
                    address = new Address {
                        value = new Value {
                            addressLocality = entryLocality.Text,
                            addressCountry  = entryCountry.Text,
                            streetAddress   = entryStreet.Text
                        }
                    },
                    dateCreated = new DateCreated {
                        type = "DateTime", value = dateTime
                    },
                    dateModified = new DateModified {
                        type = "DateTime", value = dateTime
                    },
                    description = new Description {
                        value = entryDescription.Text
                    },
                    name = new Name {
                        value = entryName.Text
                    }
                });
            }
            else
            {
                await manager.Update(new AgriFarm {
                    id   = entryID.Text,
                    name = new Name {
                        value = entryName.Text
                    },
                    address = new Address
                    {
                        value = new Value
                        {
                            addressLocality = entryLocality.Text,
                            addressCountry  = entryCountry.Text,
                            streetAddress   = entryStreet.Text
                        }
                    },
                    dateModified = new DateModified {
                        type = "DateTime", value = dateTime
                    },
                    description = new Description {
                        value = entryDescription.Text
                    }
                });
            }

            await Navigation.PopModalAsync();

            /*
             * if (!string.IsNullOrWhiteSpace(entryID.Text))
             * {
             *  await App.FarmDatabase.SaveFarmAsync(new Farm
             *  {
             *      ID = int.Parse(entryID.Text),
             *      Name = entryName.Text,
             *      Description = entryDescription.Text,
             *      Street = entryStreet.Text,
             *      Locality = entryLocality.Text,
             *      Country = entryCountry.Text
             *  });
             * }
             * else
             * {
             *  await App.FarmDatabase.SaveFarmAsync(new Farm
             *  {
             *      Name = entryName.Text,
             *      Description = entryDescription.Text,
             *      Street = entryStreet.Text,
             *      Locality = entryLocality.Text,
             *      Country = entryCountry.Text
             *  });
             * }
             * await Navigation.PopModalAsync();
             */
            instance = null;
        }
 protected override bool OnBackButtonPressed()
 {
     instance = null;
     return(base.OnBackButtonPressed());
 }
        private async void OnCancelButtonClicked(object sender, EventArgs e)
        {
            await Navigation.PopModalAsync();

            instance = null;
        }