Files
Backend-Api/CompanyManagment.EFCore/Repository/EmployeeClientTempRepository.cs
2025-03-09 21:52:06 +03:30

35 lines
1.2 KiB
C#

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<long, EmployeeClientTemp>, 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();
}
}