using Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Models.Helpers;
using Models.Interfaces;
using Models.Models;

namespace Models.Repositories
{
    public class PhOhArcataxTypeRepository (PhronCareOperationsHubContext context) : IPhOhArcataxTypeRepository
    {
        #region Declaraciones y Constructor
        private readonly PhronCareOperationsHubContext _context = context;
        #endregion
        #region Metodos de clase
        public async Task<IEnumerable<ETaxType>> GetAllActiveAsync()
        {
            var taxTypes= await _context.PhOhArcataxTypes
                .Where(t => t.IsActive)
                .Select(t => new PhOhArcataxType
                {
                    Id = t.Id,
                    TaxCode = t.TaxCode,
                    Description = t.Description,
                    Taxrate=t.Taxrate,
                    IsActive=t.IsActive
                })
                .ToListAsync();

            return taxTypes.Select(EntityMapper.MapEntity<PhOhArcataxType, ETaxType>);
        }
        #endregion
    }
}
