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

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

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

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