public FullAdd_Wine(Wine b)
        {
            InitializeComponent();
            BGImage.Source = ImageSource.FromResource("BoozeHound.wine_background.png");
            isNew          = false;
            wine           = b;

            Wine_Name.Text = wine.Name;
            wineRating.SetRating(wine.Rating);
            Wine_ABV.Text     = wine.ABV?.ToString();
            Wine_Winery.Text  = wine.Winery;
            Wine_Type.Text    = wine.Type;
            Wine_Vintage.Text = wine.Vintage?.ToString();
            Wine_Notes.Text   = wine.Notes;

            DateLabel.IsVisible = true;
            DateLabel.Text      = $"{wine.Name} added on {wine.Date.ToShortDateString()}";

            tap.Tapped += Image_Tapped;

            if (!string.IsNullOrEmpty(wine.ImagePath))
            {
                WineImage.Source = ImageSource.FromFile(wine.ImagePath);
                WineImage.GestureRecognizers.Add(tap);
                imagePopup.SetImage(wine.ImagePath);
            }
            else
            {
                WineImage.Source = ImageSource.FromResource("BoozeHound.wine_bottle.png");
            }
        }
 public FullAdd_Wine()
 {
     InitializeComponent();
     BGImage.Source   = ImageSource.FromResource("BoozeHound.wine_background.png");
     isNew            = true;
     wine             = new Wine();
     WineImage.Source = ImageSource.FromResource("BoozeHound.wine_bottle.png");
     tap.Tapped      += Image_Tapped;
 }
Exemplo n.º 3
0
 public static void UpdateWine(Wine wine)
 {
     try
     {
         wine.Name   = wine.Name.ToUpper();
         wine.Winery = wine.Winery?.ToUpper();
         wine.Type   = wine.Type?.ToUpper();
         Database.Update(wine);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Exception in UpdateWine(): {0}", ex.Message);
     }
 }
Exemplo n.º 4
0
 public static void SaveWine(Wine wine)
 {
     try
     {
         wine.Date   = DateTime.Now;
         wine.Name   = wine.Name.ToUpper();
         wine.Winery = wine.Winery?.ToUpper();
         wine.Type   = wine.Type?.ToUpper();
         Database.Insert(wine);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Exception in SaveWine(): {0}", ex.Message);
     }
 }
Exemplo n.º 5
0
        public static void DeleteWine(Wine wine)
        {
            try
            {
                if (!string.IsNullOrEmpty(wine.ImagePath))
                {
                    File.Delete(wine.ImagePath);
                }

                Database.Delete <Wine>(wine.Id);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception in DeleteWine(): {0}", ex.Message);
            }
        }
Exemplo n.º 6
0
        private async void WineList_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            string action = await DisplayActionSheet("", "Cancel", "Delete", "View");

            Wine wine = (Wine)e.Item;

            if (action == "View")
            {
                App.Current.MainPage = new FullAdd_Wine(wine);
            }
            else if (action == "Delete")
            {
                bool delete = await DisplayAlert("Delete Wine", $"Are you sure you want to permanently delete {wine.Name}?", "Yes", "No");

                if (delete)
                {
                    DataAccess.DeleteWine(wine);
                    WineList.ItemsSource = DataAccess.GetWines();
                    await DisplayAlert("", $"{wine.Name} has been deleted.", "Ok");
                }
            }
        }
Exemplo n.º 7
0
        private void BtnSaveQAWine_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(QAWine_Name.Text))
            {
                App.Current.MainPage.DisplayAlert("", "Name required.", "Ok");
                return;
            }

            if (wineRating.Rating == 0)
            {
                App.Current.MainPage.DisplayAlert("", "Rating required.", "Ok");
                return;
            }

            Wine add = new Wine()
            {
                Name = QAWine_Name.Text, Rating = wineRating.Rating, Winery = QAWine_Winery.Text
            };

            DataAccess.SaveWine(add);
            IsVisible = false;
            ClearForm();
            App.Current.MainPage.DisplayAlert("", add.Name + " saved to database.", "Ok");
        }