Ejemplo n.º 1
0
        async void OnDeleteButtonClicked(object sender, EventArgs e)
        {
            AgriParcel agriParcel = (AgriParcel)BindingContext;
            await manager.Delete(agriParcel.id);

            //Pasture pasture = (Pasture)BindingContext;
            //await App.PastureDatabase.DeletePastureAsync(pasture);
            await Navigation.PopModalAsync();

            instance = null;
        }
Ejemplo n.º 2
0
 async void OnButtonAddClicked(object sender, EventArgs e)
 {
     if (PastureDetailPage.instance == null)
     {
         PastureDetailPage.buttonDeleteVisibility = false;
         var page = new NavigationPage(PastureDetailPage.GetInstance());
         page.BarBackgroundColor = Color.FromHex("0078D7");
         MessagingCenter.Send(GenerateNewAgriParcelWithId(), "AddItem");
         await Navigation.PushModalAsync(page);
     }
 }
Ejemplo n.º 3
0
        public static PastureDetailPage GetInstance()
        {
            lock (_lock)
            {
                if (instance == null)
                {
                    instance = new PastureDetailPage();
                }

                return(instance);
            }
        }
Ejemplo n.º 4
0
 async void OnItemEditClicked(object sender, EventArgs e)
 {
     if (PastureDetailPage.instance == null && listViewPasture.SelectedItem != null)
     {
         PastureDetailPage.buttonDeleteVisibility = true;
         var page = new NavigationPage(PastureDetailPage.GetInstance());
         page.BarBackgroundColor = Color.FromHex("0078D7");
         page.BindingContext     = App.SelectedAgriParcel;
         await Navigation.PushModalAsync(page);
     }
     //if (PastureDetailPage.instance == null && listViewPasture.SelectedItem != null)
     //{
     //    PastureDetailPage.buttonDeleteVisibility = true;
     //    var page = new NavigationPage(PastureDetailPage.GetInstance());
     //    page.BarBackgroundColor = Color.FromHex("0078D7");
     //    page.BindingContext = App.SelectedPasture;
     //    //listViewFarm.SelectedItem = null;
     //    await Navigation.PushModalAsync(page);
     //}
 }
Ejemplo n.º 5
0
        async void OnSaveButtonClicked(object sender, EventArgs e)
        {
            string dateTime = DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ss.ff'Z'");

            float area;

            float.TryParse(entryArea.Text, out area);

            if (string.IsNullOrWhiteSpace(entryID.Text))
            {
                await manager.Add(new AgriParcel
                {
                    id          = id,
                    type        = "AgriParcel",
                    dateCreated = new DateCreated {
                        type = "DateTime", value = dateTime
                    },
                    dateModified = new DateModified {
                        type = "DateTime", value = dateTime
                    },
                    description = new Description {
                        value = entryDescription.Text
                    },
                    area = new Area {
                        value = area
                    }
                });
            }
            else
            {
                await manager.Update(new AgriParcel
                {
                    id   = entryID.Text,
                    area = new Area {
                        value = area
                    },
                    description = new Description {
                        value = entryDescription.Text
                    }
                });
            }

            await Navigation.PopModalAsync();

            //Pasture pasture = App.SelectedPasture;

            //float area;

            //float.TryParse(entryArea.Text, out area);
            //if (!string.IsNullOrWhiteSpace(entryID.Text))
            //{
            //    await App.PastureDatabase.SavePastureAsync(new Pasture
            //    {
            //        ID = int.Parse(entryID.Text),
            //        Area = area,
            //        Description = entryDescription.Text,
            //        FarmID = App.SelectedFarm.ID
            //    });
            //}
            //else
            //{
            //    await App.PastureDatabase.SavePastureAsync(new Pasture
            //    {
            //        Area = area,
            //        Description = entryDescription.Text,
            //        FarmID = App.SelectedFarm.ID
            //    });
            //}
            //await Navigation.PopModalAsync();
            instance = null;
        }
Ejemplo n.º 6
0
 protected override bool OnBackButtonPressed()
 {
     instance = null;
     return(base.OnBackButtonPressed());
 }
Ejemplo n.º 7
0
        async void OnCancelButtonClicked(object sender, EventArgs e)
        {
            await Navigation.PopModalAsync();

            instance = null;
        }