using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Reflection; using MTWorkHR.Application.Services.Interfaces; using MTWorkHR.Core.UnitOfWork; using MTWorkHR.Core.IRepositories.Base; namespace MTWorkHR.Application.Services { public class LogService: ILogService where TEntity : class { private readonly IUnitOfWorkLog unitOfWork; //private readonly IRepository repository; public LogService(IUnitOfWorkLog _unitOfWork) { unitOfWork = _unitOfWork; //this.repository = repository; //repository = (IRepository)unitOfWork.GetRepositoryByName(typeof(TEntity).Name); } public virtual async Task Create(TEntity input) { IRepositoryLog repository = (IRepositoryLog)unitOfWork.GetRepositoryByName(input.GetType().Name); //var repository = (IRepository)value; await repository.AddAsync(input); await unitOfWork.CompleteAsync(); } } }