using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime;
using System.Text;
using System.Threading.Tasks;

namespace NightScout
{
    public class MultiAlerter : IAlerter
    {
        public List<IAlerter> Alerters { get; set; }

        public MultiAlerter(IEnumerable<IAlerter> alerters)
        {
            Alerters = new List<IAlerter>(alerters);
        }
        public void StartAlert()
        {
            Alerters.ForEach(a =>
            {
                try
                {
                    a.StartAlert();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            });

        }

        public void StartUrgentAlert()
        {
            Alerters.ForEach(a =>
            {
                try
                {
                    a.StartUrgentAlert();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            });
        }

        public void StartStaleDataAlert()
        {
            Alerters.ForEach(a =>
            {
                try
                {
                    a.StartStaleDataAlert();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            });
        }

        public void StopAlerts()
        {

            Alerters.ForEach(a =>
            {
                try
                {
                    a.StopAlerts();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                } 
            });

        }
    }
}
