using System.Linq;
using Rainbow.Models;

namespace Rainbow.Data
{
    public class RegistrarsRepository : GenericRepository<Registrar>, IRegistrarsRepository
    {
        public RegistrarsRepository(RainbowContext context)
            : base(context)
        {            
        }

        public Registrar GetByName(string name)
        {
            return Context.Registrars.SingleOrDefault(d => d.Name == name);
        }

        public bool IsInUse(int id)
        {
            return Context.Domains.Count(d => d.RegistrarId == id) > 0;
        }
    }
}
