67 lines
3.1 KiB
C#
67 lines
3.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using _0_Framework.Application;
|
|
using Company.Domain.EmployeeAgg;
|
|
using Company.Domain.EmployeeDocumentItemAgg;
|
|
using Company.Domain.EmployeeDocumentsAdminSelectionAgg;
|
|
using CompanyManagment.App.Contracts.EmployeeDocumentsAdminSelection;
|
|
|
|
namespace CompanyManagment.Application
|
|
{
|
|
public class EmployeeDocumentsAdminSelectionApplication :IEmployeeDocumentsAdminSelectionApplication
|
|
{
|
|
private readonly IEmployeeDocumentsAdminSelectionRepository _employeeDocumentsAdminViewRepository;
|
|
private readonly IEmployeeDocumentItemRepository _employeeDocumentItemRepository;
|
|
private readonly IEmployeeRepository _employeeRepository;
|
|
public EmployeeDocumentsAdminSelectionApplication(IEmployeeDocumentsAdminSelectionRepository employeeDocumentsAdminViewRepository, IEmployeeDocumentItemRepository employeeDocumentItemRepository, IEmployeeRepository employeeRepository)
|
|
{
|
|
_employeeDocumentsAdminViewRepository = employeeDocumentsAdminViewRepository;
|
|
_employeeDocumentItemRepository = employeeDocumentItemRepository;
|
|
_employeeRepository = employeeRepository;
|
|
}
|
|
|
|
//public OperationResult SelectDocumentItem(SelectEmployeeDocumentItem command)
|
|
//{
|
|
|
|
// OperationResult op= new();
|
|
// EmployeeDocumentsAdminSelection adminDocuments = _employeeDocumentsAdminViewRepository.GetByEmployeeIdWithItems(command.EmployeeId);
|
|
|
|
// if (adminDocuments == null)
|
|
// return op.Failed("رکورد مورد نظر یافت نشد");
|
|
|
|
// var documentItem = _employeeDocumentItemRepository.Get(command.EmployeeDocumentItemId);
|
|
// if (documentItem == null)
|
|
// return op.Failed("رکورد مورد نظر یافت نشد");
|
|
|
|
|
|
// var existingItem=adminDocuments.SelectedEmployeeDocumentItems.FirstOrDefault(x => x.DocumentLabel == documentItem.DocumentLabel);
|
|
// if(existingItem != null)
|
|
// existingItem.AdminDeselect();
|
|
// documentItem.AdminSelect(adminDocuments.id);
|
|
// _employeeDocumentsAdminViewRepository.SaveChanges();
|
|
|
|
// return op.Succcedded();
|
|
//}
|
|
|
|
//public List<EmployeeDocumentsAdminSelectionViewModel> Search(SearchEmployeeDocumentsAdminSelection command)
|
|
//{
|
|
// return _employeeDocumentsAdminViewRepository.Search(command);
|
|
//}
|
|
|
|
//public OperationResult Create(long employeeId)
|
|
//{
|
|
// OperationResult op = new();
|
|
// if(!_employeeRepository.Exists(x=>x.id==employeeId))
|
|
// return op.Failed("رکورد مورد نظر یافت نشد");
|
|
|
|
// if (_employeeDocumentsAdminViewRepository.Exists(x => x.EmployeeId == employeeId))
|
|
// return op.Failed("رکورد تکراری است");
|
|
// var entity = new EmployeeDocumentsAdminSelection(employeeId);
|
|
// _employeeDocumentsAdminViewRepository.Create(entity);
|
|
// _employeeDocumentsAdminViewRepository.SaveChanges();
|
|
|
|
// return op.Succcedded(entity.id);
|
|
//}
|
|
}
|
|
}
|