using System.Collections.Generic;
using System.Linq;
using CounterDrone.Core.Models;
using SQLite;

namespace CounterDrone.Core.Repository
{
    public class ScenarioDroneRepository : BaseRepository<ScenarioDrone>
    {
        public ScenarioDroneRepository(SQLiteConnection db) : base(db) { }

        public List<ScenarioDrone> GetByScenarioId(string scenarioId)
        {
            return Db.Table<ScenarioDrone>().Where(t => t.ScenarioId == scenarioId).ToList();
        }

        public void DeleteByScenarioId(string scenarioId)
        {
            var drones = GetByScenarioId(scenarioId);
            foreach (var t in drones)
                Db.Delete(t);
        }
    }
}
