using System.Linq; using _0_Framework.Application; using _0_Framework.InfraStructure; using Company.Domain.EmployeeClientTempAgg; using CompanyManagment.App.Contracts.EmployeeClientTemp; namespace CompanyManagment.EFCore.Repository; public class EmployeeClientTempRepository: RepositoryBase, IEmployeeClientTempRepository { private readonly CompanyContext _context; public EmployeeClientTempRepository(CompanyContext context): base(context) { _context = context; } public EmployeeClientTemp GetByEmployeeIdAndWorkshopId(long employeeId, long commandWorkshopId) { return _context.EmployeeClientTemps.FirstOrDefault(x => x.EmployeeId == employeeId && x.WorkshopId == commandWorkshopId); } public EmployeeClientTempGetDetailsViewModel GetDetails(long employeeId, long workshopId) { return _context.EmployeeClientTemps .Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId) .Select(x => new EmployeeClientTempGetDetailsViewModel { EmployeeId = x.EmployeeId, StartWorkDate = x.StartWorkDate.ToFarsi(), WorkshopId = x.WorkshopId }).FirstOrDefault(); } }