using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.Core.Repositories.Interfaces.Unit;
using PARR.DAL.Context;
using PARR.DAL.Repositories.Base;
using PARR.Domain.Entities.Unit;

namespace PARR.DAL.Repositories.Unit
{
    internal class UnitFieldRepository : BaseRepository<UnitField>, IUnitFieldRepository
    {
        public UnitFieldRepository(DataContext dataContext, ILogger<UnitFieldRepository> logger) : base(logger, dataContext) { }

        public async Task<UnitField?> GetByAihitNameAsync(string name)
        {
            return await EntitySet.FirstOrDefaultAsync(uf => uf.AihitName.ToLower().Trim() == name.ToLower().Trim());
        }
    }
}
