using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using Microsoft.Win32;
using DemoPractick.Model;
using DemoPractick.VM;

namespace DemoPractick.Model
{
   partial  class Product : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        public string MaterialType
        {
            get
            {


                string answer = string.Empty;
                List<Material> materialProductObj = new List<Material>();
                List<ProductMaterial> materialProductID = Data.Sush.ProductMaterial.Where(x => x.ProductID == ID).ToList();
                foreach (ProductMaterial ob in materialProductID)
                {
                    answer += $"{Data.Sush.Material.FirstOrDefault(x => x.ID == ob.MaterialID).Title}, ";
                }
                return answer;
            }
            set { }
        }
        public double Cena
        {
            get 
            { 
                double C = 0;
                List<Material> materialProductObj = new List<Material>();
                List<ProductMaterial> materialProductID=Data.Sush.ProductMaterial.Where(x=>x.ProductID== ID).ToList();
                foreach (ProductMaterial ob in materialProductID)
                {
                    C += Convert.ToDouble(Data.Sush.Material.FirstOrDefault(x => x.ID == ob.MaterialID).Cost) * Convert.ToDouble(ob.Count);
                }
                return C;
            }
        }
        //Заглушка фото



    }
}
