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

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

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

        public RoutePlan GetByTaskAndGroup(string taskId, string groupId)
        {
            return Db.Table<RoutePlan>()
                .FirstOrDefault(r => r.TaskId == taskId && r.GroupId == groupId);
        }
    }
}
