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

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

        public List<TargetConfig> GetByTaskId(string taskId)
        {
            return Db.Table<TargetConfig>().Where(t => t.TaskId == taskId).ToList();
        }

        public void DeleteByTaskId(string taskId)
        {
            var targets = GetByTaskId(taskId);
            foreach (var t in targets)
                Db.Delete(t);
        }
    }
}
