using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using SmartAquaViewer.DataAnalysis;
using static MaterialDesignThemes.Wpf.Theme.ToolBar;

namespace SmartAquaViewer.Model
{
    public class Datas : INotifyPropertyChanged
    {
        public static Datas Instance { get; } = new Datas();

        public ObservableCollection<WaterQualityVO> WaterQualityList { get; set; }
        public ReadOnlyObservableCollection<WaterQualityVO> WaterQualityView { get; }

        private Datas()
        {
            WaterQualityList = new ObservableCollection<WaterQualityVO>();
            WaterQualityView = new ReadOnlyObservableCollection<WaterQualityVO>(WaterQualityList);
        }

        public ObservableCollection<WaterQualityVO> GetWaterQualityVO()
        {
            return WaterQualityList;
        }

        public void SetWaterQualityVO(List<WaterQualityVO> sampleData)
        {
            WaterQualityList.Clear();
            if (sampleData == null) return;
            foreach (var data in sampleData)            
                WaterQualityList.Add(data);

            OnPropertyChanged(nameof(WaterQualityList));
        }

        public event PropertyChangedEventHandler? PropertyChanged;
        private void OnPropertyChanged(string name) =>
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }
}
