using BookStore_DataAccess.context;
using BookStore_DataAccess.model;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BookStore_DataAccess.repository
{

    public class PublisherRepository : IRepository<Publisher>
    {
        BookStoreDataModel BookStoreContext;
        DbSet<Publisher> dbSet;
        public PublisherRepository(BookStoreDataModel BookStoreContext)
        {
            this.BookStoreContext = BookStoreContext;
            this.dbSet = BookStoreContext.Set<Publisher>();
        }


        public List<Publisher> GetAll()
        {
            return dbSet.ToList<Publisher>();
        }

        public Publisher GetById(object id)
        {
            return dbSet.Find(id);
        }

        public void Insert(Publisher entity)
        {
            dbSet.Add(entity);
        }

        public void Delete(object id)
        {
            Publisher entity = GetById(id);
            dbSet.Remove(entity);
        }

        public void Update(Publisher entity)
        {
            dbSet.Attach(entity);
        }
    }
}
