using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CafeTerrace.Models.DataBase;
using CafeTerrace.ViewModels;
using Prism.Navigation;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace CafeTerrace.Views.Controller
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class BuyBagSlideMenu : ContentView , IDisposable 
    {
        public event EventHandler SubmitBuyBagClicked;
        
        public BuyBagSlideMenu()
        {
            BindingContext = new BuyBagSlideMenuViewModel(null);
            InitializeComponent();
        }



        private void BuyBagFoodItem_OnFoodRemoved(object sender, EventArgs e)
        {
            (BindingContext as BuyBagSlideMenuViewModel)?.RemoveFoodButtonCommand.Execute((sender as OrderFood));
        }

        private void BuyBagFoodItem_OnFoodAmountChanged(object sender, EventArgs e)
        {
            (BindingContext as BuyBagSlideMenuViewModel)?.FoodAmountChangedCommand.Execute(sender as OrderFood);
        }

        private void PayementButton_OnClicked(object sender, EventArgs e)
        {
            if((BindingContext as BuyBagSlideMenuViewModel).Foods.Count > 0)
                SubmitBuyBagClicked?.Invoke(this, e);

        }

        public void Dispose()
        {
            (BindingContext as BuyBagSlideMenuViewModel)?.Dispose();
        }
    }
}