using System;
using System.Linq;
using Domain;

namespace Infrastructure.Repositories.EntityFramework
{
  public class LinkRepository : ILinkRepository
  {
    private readonly HNDbContext _context;

    public LinkRepository(HNDbContext context)
    {
      _context = context;
    }

    public void Add(Link link)
    {
      _context.Links.Add(link);
      _context.SaveChanges();
    }

    public Link GetById(Guid id)
    {
      return _context.Links.Single(link => link.Id == id);
    }
  }
}