using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace modulekz
{
    /// <summary>
    /// Логика взаимодействия для ListBook.xaml
    /// </summary>
    public partial class ListBook : Page
    {

        VModel VM = new VModel();
        double sale = 0;
        int kol_vo = 0;
        List<Book> tableBooks = new List<Book>();

        public ListBook(List<Book> books)
        {
            InitializeComponent();
            sale = 0;
            tableBooks = books;
            ListBooks.ItemsSource = VM.books;
            int ii = 0;
            double c = 0;
            foreach (Book b in books)
            {
                ii += b.inc;
                sale = b.sale;
                c += Convert.ToDouble(b.Cost) * b.inc;
            }
            kol_vo = ii;
            RKol_v.Text = kol_vo.ToString();
            Rsale.Text = sale.ToString();
            FirstCost.Text = c.ToString();
            if (sale > 0)
            {
                FirstCost.TextDecorations = TextDecorations.Strikethrough;
                SecCost.Text = (c - c * (sale / 100)).ToString();
            }
        }

        private void Gocart_Click(object sender, RoutedEventArgs e)
        {

        }

        private void AddCart_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}
