using ConstructorApp.DataAccessLayer.Abstract;
using ConstructorApp.DataAccessLayer.Concrete;
using ConstructorApp.DataAccessLayer.Repositories;
using ConstructorApp.EntityLayer.Entities;

namespace ConstructorApp.DataAccessLayer.EntityFramework
{
    public class EfContactUsDal : GenericRepository<ContactUs>, IContactUsDal
    {
        private readonly ConstructorContext context;

        public EfContactUsDal(ConstructorContext context) : base(context)
        {
            this.context = context;
        }

        public int CountAll()
        {
            return context.ContactUs.Count();
        }

        public int CountByStatusPending()
        {
            return context.ContactUs.Where(x => x.Status == false).Count();
        }

        public void MarkAsRead(int id)
        {
            var values = context.ContactUs.Find(id);
            values.Status = true;
            context.SaveChanges();
        }
    }
}
