﻿using SciReview.Common.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;

namespace SciReview.DataAccess.Repositories
{
    public class AuthorRepository : IRepository<ArticleAuthor>
    {
        private IDbConnectionFactory db;

        public AuthorRepository(IDbConnectionFactory database)
        {
            this.db = database;
        }

        public ArticleAuthor GetById(int id)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<ArticleAuthor> GetByName(string name)
        {
            throw new NotImplementedException();
        }

        public int Insert(ArticleAuthor item)
        {
            using(var conn = db.GetOpenConnection())
            {
                var sql = @"INSERT INTO AuthorArticle(ArticleID, FirstName, LastName, Email, DegreeID)
                            VALUES (@ArticleID, @FirstName, @LastName, @Email, @DegreeID);";

                return conn.Execute(sql, item);
            }
        }

        public void Update(ArticleAuthor item)
        {
            throw new NotImplementedException();
        }

        public void Delete(int id)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<ArticleAuthor> GetAll()
        {
            throw new NotImplementedException();
        }

        public IEnumerable<ArticleAuthor> GetByPage(Pagination pagination, out int totalRecords)
        {
            throw new NotImplementedException();
        }
    }
}
