73 lines
3.6 KiB
C#
73 lines
3.6 KiB
C#
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using _0_Framework.Application;
|
|
using _0_Framework.InfraStructure;
|
|
using AccountMangement.Infrastructure.EFCore;
|
|
using Company.Domain.EmployeeDocumentsAdminSelectionAgg;
|
|
using CompanyManagment.App.Contracts.EmployeeDocuments;
|
|
using CompanyManagment.App.Contracts.EmployeeDocumentsAdminSelection;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace CompanyManagment.EFCore.Repository;
|
|
|
|
public class EmployeeDocumentsAdminSelectionRepository : RepositoryBase<long,EmployeeDocumentsAdminSelection>,IEmployeeDocumentsAdminSelectionRepository
|
|
{
|
|
private readonly CompanyContext _companyContext;
|
|
private readonly AccountContext _accountContext;
|
|
public EmployeeDocumentsAdminSelectionRepository(CompanyContext context, CompanyContext companyContext, AccountContext accountContext) : base(context)
|
|
{
|
|
_companyContext = companyContext;
|
|
_accountContext = accountContext;
|
|
}
|
|
|
|
//public List<EmployeeDocumentsAdminSelectionViewModel> Search(SearchEmployeeDocumentsAdminSelection command)
|
|
//{
|
|
// var query = _companyContext.EmployeeDocumentsAdminSelectionSet.Include(x => x.Employee)
|
|
// .Include(x => x.SelectedEmployeeDocumentItems).ThenInclude(x=>x.EmployeeDocuments).AsQueryable();
|
|
|
|
// if (!string.IsNullOrWhiteSpace(command.EmployeeName))
|
|
// query = query.Where(x => (x.Employee.FName+" "+x.Employee.LName).Contains(command.EmployeeName));
|
|
|
|
// var items = query.SelectMany(x => x.SelectedEmployeeDocumentItems);
|
|
|
|
|
|
// //get selected documents mediaIds
|
|
// var mediaIds = items.Select(x => x.MediaId);
|
|
|
|
// var medias = _accountContext.Medias.Where(x => mediaIds.Contains(x.id));
|
|
|
|
|
|
// var joinedList = items.Join(medias, x => x.MediaId, y => y.id, (x, y) => new
|
|
// {
|
|
// Label = x.DocumentLabel,
|
|
// Path = y.Path
|
|
// });
|
|
|
|
// return query.Select(x => new EmployeeDocumentsAdminSelectionViewModel()
|
|
// {
|
|
// EmployeeId = x.EmployeeId,
|
|
// EducationalDegreePicturePath =
|
|
// joinedList.FirstOrDefault(y => y.Label == DocumentItemLabel.EducationalDegree).Path,
|
|
// EmployeeFullName = x.Employee.FullName,
|
|
// EmployeePicturePath = joinedList.FirstOrDefault(y => y.Label == DocumentItemLabel.EmployeePicture).Path,
|
|
// Gender = x.Employee.Gender,
|
|
// IdCardPage1PicturePath = joinedList.FirstOrDefault(y => y.Label == DocumentItemLabel.IdCardPage1).Path,
|
|
// IdCardPage2PicturePath = joinedList.FirstOrDefault(y => y.Label == DocumentItemLabel.IdCardPage2).Path,
|
|
// IdCardPage3PicturePath = joinedList.FirstOrDefault(y => y.Label == DocumentItemLabel.IdCardPage3).Path,
|
|
// IdCardPage4PicturePath = joinedList.FirstOrDefault(y => y.Label == DocumentItemLabel.IdCardPage4).Path,
|
|
// MilitaryServiceCardPicturePath =
|
|
// joinedList.FirstOrDefault(y => y.Label == DocumentItemLabel.MilitaryServiceCard).Path,
|
|
// NationalCardFrontPicturePath =
|
|
// joinedList.FirstOrDefault(y => y.Label == DocumentItemLabel.NationalCardFront).Path,
|
|
// NationalCardRearPicturePath = joinedList.FirstOrDefault(y=>y.Label==DocumentItemLabel.NationalCardRear).Path,
|
|
// }).ToList();
|
|
//}
|
|
|
|
//public EmployeeDocumentsAdminSelection GetByEmployeeIdWithItems(long employeeId)
|
|
//{
|
|
// return _companyContext.EmployeeDocumentsAdminSelectionSet.Include(x => x.SelectedEmployeeDocumentItems).Include(x=>x.Employee)
|
|
// .FirstOrDefault(x => x.EmployeeId == employeeId);
|
|
//}
|
|
} |