workshopSelectList api and employeeSelectlist
This commit is contained in:
@@ -84,6 +84,12 @@ public interface ICheckoutRepository : IRepository<long, Checkout>
|
||||
|
||||
|
||||
#region ForApi
|
||||
/// <summary>
|
||||
/// دریافت سلکت لیست پرسنل کارگاه
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EmployeeSelectListDto>> GetEmployeeSelectListByWorkshopId(long id);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست فیش حقوقی
|
||||
|
||||
@@ -106,4 +106,14 @@ public interface IWorkshopRepository : IRepository<long, Workshop>
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ForApi
|
||||
/// <summary>
|
||||
/// دریافت لیست کارگاه های ادمین برای سلکت تو
|
||||
/// Api
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<AdminWorkshopSelectListDto>> GetAdminWorkshopSelectList();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace CompanyManagment.App.Contracts.Checkout.Dto;
|
||||
|
||||
public class EmployeeSelectListDto
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی پرسنل
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام پرسنل
|
||||
/// </summary>
|
||||
public string EmployeeFullName { get; set; }
|
||||
}
|
||||
@@ -67,6 +67,13 @@ public interface ICheckoutApplication
|
||||
|
||||
#region ForApi
|
||||
|
||||
/// <summary>
|
||||
/// دریافت سلکت لیست پرسنل کارگاه
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EmployeeSelectListDto>> GetEmployeeSelectListByWorkshopId(long id);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست فیش های حقوقی ادمین
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace CompanyManagment.App.Contracts.Workshop.DTOs;
|
||||
|
||||
public class AdminWorkshopSelectListDto
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی کارگاه
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کارگاه
|
||||
/// </summary>
|
||||
public string WorkshopFullName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// کد بایگانی
|
||||
/// </summary>
|
||||
public string ArchiveCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آیا بلاک شده است
|
||||
/// </summary>
|
||||
public bool IsBlock { get; set; }
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using CompanyManagment.App.Contracts.Checkout.Dto;
|
||||
using CompanyManagment.App.Contracts.Workshop.DTOs;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Workshop;
|
||||
|
||||
@@ -92,6 +93,19 @@ public interface IWorkshopApplication
|
||||
#endregion
|
||||
|
||||
Task<ActionResult<OperationResult>> CreateWorkshopWorkflowRegistration(CreateWorkshopWorkflowRegistration command);
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست کارگاه های ادمین برای سلکت تو
|
||||
/// Api
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<AdminWorkshopSelectListDto>> GetAdminWorkshopSelectList();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class CreateWorkshopWorkflowRegistration
|
||||
|
||||
@@ -717,7 +717,10 @@ public class CheckoutApplication : ICheckoutApplication
|
||||
return _checkoutRepository.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, start, end);
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<EmployeeSelectListDto>> GetEmployeeSelectListByWorkshopId(long id)
|
||||
{
|
||||
return await _checkoutRepository.GetEmployeeSelectListByWorkshopId(id);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ using Company.Domain.InstitutionContractAgg;
|
||||
using Company.Domain.LeftWorkAgg;
|
||||
using Company.Domain.LeftWorkInsuranceAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagment.App.Contracts.Checkout.Dto;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.EmployeeChildren;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
@@ -1130,5 +1131,17 @@ public class WorkshopAppliction : IWorkshopApplication
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
public async Task<List<AdminWorkshopSelectListDto>> GetAdminWorkshopSelectList()
|
||||
{
|
||||
return await _workshopRepository.GetAdminWorkshopSelectList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -2762,6 +2762,22 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
|
||||
#region ForApi
|
||||
|
||||
public async Task<List<EmployeeSelectListDto>> GetEmployeeSelectListByWorkshopId(long id)
|
||||
{
|
||||
var employeesHasLeftworkData =_context.LeftWorkList.Where(x => x.WorkshopId == id).Select(x => x.EmployeeId);
|
||||
var employees =await _context.Employees
|
||||
.Where(x => employeesHasLeftworkData.Contains(x.id))
|
||||
.Select(x =>
|
||||
new EmployeeSelectListDto()
|
||||
{
|
||||
Id = x.id,
|
||||
EmployeeFullName = x.FullName
|
||||
})
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
return employees;
|
||||
}
|
||||
|
||||
public async Task<PagedResult<CheckoutDto>> GetList(CheckoutSearchModelDto searchModel)
|
||||
{
|
||||
var acountID = _authHelper.CurrentAccountId();
|
||||
@@ -3236,5 +3252,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
Console.WriteLine("print : " + watch.Elapsed);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -2024,5 +2024,52 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
|
||||
}).OrderByDescending(x => x.StartWork).ToList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
public async Task<List<AdminWorkshopSelectListDto>> GetAdminWorkshopSelectList()
|
||||
{
|
||||
var watch = new Stopwatch();
|
||||
watch.Start();
|
||||
var acountId = _authHelper.CurrentAccountId();
|
||||
|
||||
var workshopIds = _context.WorkshopAccounts.AsNoTracking().Where(x => x.AccountId == acountId).Select(x => x.WorkshopId);
|
||||
|
||||
var employers = await
|
||||
_context.WorkshopEmployers.AsNoTracking().Where(x => workshopIds.Contains(x.WorkshopId))
|
||||
.Select(x => new { x.Employer, x.WorkshopId }).ToListAsync();
|
||||
|
||||
var blockedContractingParties =await _context.PersonalContractingParties
|
||||
.Where(x => x.IsBlock == "true").Select(x=>x.id).ToListAsync();
|
||||
|
||||
var workshops = await _context.Workshops.AsNoTracking()
|
||||
.Where(x => workshopIds.Contains(x.id))
|
||||
.Where(x => x.IsActiveString == "true").ToListAsync();
|
||||
|
||||
|
||||
var result = workshops.Select(x =>
|
||||
{
|
||||
var empl = employers.First(em => em.WorkshopId == x.id);
|
||||
var isBlock = blockedContractingParties.Any(cp => cp == empl.Employer.ContractingPartyId);
|
||||
return new AdminWorkshopSelectListDto
|
||||
{
|
||||
Id = x.id,
|
||||
WorkshopFullName = x.WorkshopFullName,
|
||||
ArchiveCode = x.ArchiveCode,
|
||||
IsBlock = isBlock
|
||||
};
|
||||
|
||||
}).OrderBy(x=>x.IsBlock ? 1 : 0)
|
||||
.ToList();
|
||||
|
||||
Console.WriteLine("workshopSelectList : " +watch.Elapsed);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Checkout.Dto;
|
||||
using CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using CompanyManagment.App.Contracts.Workshop.DTOs;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NuGet.Packaging.Signing;
|
||||
using ServiceHost.BaseControllers;
|
||||
@@ -11,10 +13,12 @@ namespace ServiceHost.Areas.Admin.Controllers;
|
||||
public class CheckoutController : AdminBaseController
|
||||
{
|
||||
private readonly ICheckoutApplication _checkoutApplication;
|
||||
private readonly IWorkshopApplication _workshopApplication;
|
||||
|
||||
public CheckoutController(ICheckoutApplication checkoutApplication)
|
||||
public CheckoutController(ICheckoutApplication checkoutApplication, IWorkshopApplication workshopApplication)
|
||||
{
|
||||
_checkoutApplication = checkoutApplication;
|
||||
_workshopApplication = workshopApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -64,5 +68,31 @@ public class CheckoutController : AdminBaseController
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#region CreateCheckout
|
||||
/// <summary>
|
||||
/// سلکت لیست کارگاه
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("WorkshopSelectList")]
|
||||
public async Task<List<AdminWorkshopSelectListDto>> GetWorkshopSelectList()
|
||||
{
|
||||
var result =await _workshopApplication.GetAdminWorkshopSelectList();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// سلک لیست پرسنل
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("EmployeeSelectList")]
|
||||
public async Task<List<EmployeeSelectListDto>> GetEmployeeSelectListByWorkshopId(long workshopId)
|
||||
{
|
||||
var result = await _checkoutApplication.GetEmployeeSelectListByWorkshopId(workshopId);
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user