using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Models.Leave.Commons;
using BMA.EHR.Domain.Models.Leave.Requests;
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
using Microsoft.EntityFrameworkCore;

namespace BMA.EHR.Infrastructure.Persistence
{
    public class LeaveDbContext : DbContext, ILeaveDbContext
    {
        #region " Check-In "

        public DbSet<DutyTime> DutyTimes { get; set; }

        public DbSet<UserTimeStamp> UserTimeStamps { get; set; }

        public DbSet<ProcessUserTimeStamp> ProcessUserTimeStamps { get; set; }

        public DbSet<UserDutyTime> UserDutyTimes { get; set; }

        public DbSet<AdditionalCheckRequest> AdditionalCheckRequests { get; set; }

        public DbSet<UserCalendar> UserCalendars { get; set; }

        #endregion

        #region " Leave System "

        public DbSet<LeaveType> LeaveTypes { get; set; }

        public DbSet<LeaveRequest> LeaveRequests { get; set; }

        public DbSet<LeaveDocument> LeaveDocuments { get; set; }


        #endregion


        public LeaveDbContext(DbContextOptions<LeaveDbContext> options) : base(options)
        {
        }

        public Task<int> SaveChangesAsync()
        {
            return base.SaveChangesAsync();
        }

        public void Attatch<T>(T entity) where T : class
        {
            Attach(entity);
        }

        public void Detach<T>(T entity) where T : class
        {
            base.Entry(entity).State = EntityState.Detached;
        }
    }
}
