52 lines
1.9 KiB
C#
52 lines
1.9 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using _0_Framework.Application;
|
|
using _0_Framework.InfraStructure;
|
|
using Company.Domain.EmployeeClientTempAgg;
|
|
using CompanyManagment.App.Contracts.EmployeeClientTemp;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
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();
|
|
}
|
|
|
|
public async Task<List<EmployeeClientTempViewModel>> GetByEmployeeId(long employeeId)
|
|
{
|
|
return await _context.EmployeeClientTemps.Where(x => x.EmployeeId == employeeId).Select(x =>
|
|
new EmployeeClientTempViewModel()
|
|
{
|
|
EmployeeId = x.EmployeeId,
|
|
WorkshopId = x.WorkshopId,
|
|
EmployeeFullName = x.EmployeeFullName,
|
|
MaritalStatus = x.MaritalStatus,
|
|
StartWorkDate = x.StartWorkDate
|
|
|
|
}).ToListAsync();
|
|
}
|
|
} |