JobSelectList api
This commit is contained in:
@@ -17,7 +17,7 @@ public interface IJobRepository : IRepository<long, Job>
|
||||
/// </summary>
|
||||
/// <param name="searchtText"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<JobViewModel>> JobSearchSelect(string searchtText);
|
||||
Task<List<JobListDto>> JobSearchSelect(string searchtText);
|
||||
// Task<List<JobViewModel>> GetJobListByText(string searchtText);
|
||||
List<JobViewModel> GetJobListByText(string searchtText);
|
||||
List<JobViewModel> GetJobListByWorkshopId(long workshopId);
|
||||
|
||||
@@ -13,13 +13,13 @@ public interface IJobApplication
|
||||
List<JobViewModel> Search(JobSearchModel searchModel);
|
||||
List<JobViewModel> SearchJobForMain(JobSearchModel searchModel);
|
||||
//Task<List<JobViewModel>> GetJobListByText(string searchtText);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// جستجوی مشاغل برای سلکت تو
|
||||
/// </summary>
|
||||
/// <param name="searchtText"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<JobViewModel>> JobSearchSelect(string searchtText);
|
||||
Task<List<JobListDto>> JobSearchSelect(string searchtText);
|
||||
List<JobViewModel> GetJobListByText(string searchtText);
|
||||
List<JobViewModel> GetJobListByWorkshopId(long workshopId);
|
||||
List<JobViewModel> GetJobListByTextAndWorkshopId(string textSearch, long workshopId);
|
||||
|
||||
@@ -7,4 +7,11 @@ public class JobViewModel
|
||||
public string JobCode { get; set; }
|
||||
public string SearchResultTitle { get; set; }
|
||||
public string SearchResultCode { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class JobListDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string JobName { get; set; }
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class JobApplication : IJobApplication
|
||||
return _jobRepository.SearchJobForMain(searchModel);
|
||||
}
|
||||
|
||||
public async Task<List<JobViewModel>> JobSearchSelect(string searchtText)
|
||||
public async Task<List<JobListDto>> JobSearchSelect(string searchtText)
|
||||
{
|
||||
return await _jobRepository.JobSearchSelect(searchtText);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
public class JobRepository: RepositoryBase<long, Job>, IJobRepository
|
||||
public class JobRepository : RepositoryBase<long, Job>, IJobRepository
|
||||
{
|
||||
private readonly CompanyContext _context;
|
||||
public JobRepository(CompanyContext context) : base(context)
|
||||
@@ -23,7 +23,7 @@ public class JobRepository: RepositoryBase<long, Job>, IJobRepository
|
||||
Id = x.id,
|
||||
JobName = x.JobName,
|
||||
JobCode = x.JobCode
|
||||
|
||||
|
||||
|
||||
}).ToList();
|
||||
}
|
||||
@@ -31,14 +31,14 @@ public class JobRepository: RepositoryBase<long, Job>, IJobRepository
|
||||
public EditJob GetDetails(long id)
|
||||
{
|
||||
return _context.Jobs.Select(x => new EditJob
|
||||
{
|
||||
Id = x.id,
|
||||
JobName = x.JobName,
|
||||
JobCode = x.JobCode
|
||||
|
||||
{
|
||||
Id = x.id,
|
||||
JobName = x.JobName,
|
||||
JobCode = x.JobCode
|
||||
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
@@ -84,34 +84,29 @@ public class JobRepository: RepositoryBase<long, Job>, IJobRepository
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<JobViewModel>> JobSearchSelect(string searchtText)
|
||||
public async Task<List<JobListDto>> JobSearchSelect(string searchtText)
|
||||
{
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchtText))
|
||||
{
|
||||
var query =_context.Jobs.Select(x => new JobViewModel
|
||||
var query = _context.Jobs.Where(x => x.JobName.Contains(searchtText));
|
||||
|
||||
var jobViewModelList = await query.Take(100).OrderBy(x => x.JobName.Length).Select(x => new JobListDto()
|
||||
{
|
||||
Id = x.id,
|
||||
JobName = x.JobName,
|
||||
JobCode = x.JobCode
|
||||
});
|
||||
query = query.Where(x => x.JobName.Contains(searchtText));
|
||||
var jobViewModelList =await query.Take(100).Select(x => new JobViewModel
|
||||
{
|
||||
Id = x.Id,
|
||||
JobName = x.JobName,
|
||||
JobCode = x.JobCode
|
||||
JobName = $"{x.JobName} - {x.JobCode}",
|
||||
|
||||
}).ToListAsync();
|
||||
return jobViewModelList;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<JobViewModel>();
|
||||
}
|
||||
|
||||
|
||||
return new List<JobListDto>();
|
||||
|
||||
}
|
||||
|
||||
// public async Task<List<JobViewModel>> GetJobListByText(string searchtText)
|
||||
public List<JobViewModel> GetJobListByText(string searchtText)
|
||||
public List<JobViewModel> GetJobListByText(string searchtText)
|
||||
{
|
||||
var query = _context.Jobs.Select(x => new JobViewModel
|
||||
{
|
||||
@@ -143,7 +138,7 @@ public class JobRepository: RepositoryBase<long, Job>, IJobRepository
|
||||
var jobViewModelList = query.Take(100).Select(x => new JobViewModel
|
||||
{
|
||||
Id = x.Id,
|
||||
JobName = x.JobName+ " " + '-' + " " + x.JobCode,
|
||||
JobName = x.JobName + " " + '-' + " " + x.JobCode,
|
||||
JobCode = x.JobCode
|
||||
}).ToList();
|
||||
return jobViewModelList;
|
||||
@@ -156,12 +151,12 @@ public class JobRepository: RepositoryBase<long, Job>, IJobRepository
|
||||
List<long> jobIds = new List<long>();
|
||||
if (workshop != null && workshop.FixedSalary)
|
||||
{
|
||||
insuranceJobId = workshop.InsuranceJobId == null? 0 : (long)workshop.InsuranceJobId;
|
||||
insuranceJobId = workshop.InsuranceJobId == null ? 0 : (long)workshop.InsuranceJobId;
|
||||
var insuranceJobIteIds = _context.InsuranceJobItems.Where(x => x.InsuranceJobId == insuranceJobId).Select(x => x.id).ToList();
|
||||
jobIds = _context.InsuranceJobAndJobsSet.Where(x => insuranceJobIteIds.Contains(x.InsuranceJobItemId)).Select(x => x.JobId).ToList();
|
||||
}
|
||||
//id==10 --->کارفرما اضافه می شود
|
||||
var query = _context.Jobs.Where(x=>x.id==10 || jobIds.Contains(x.id)).Select(x => new JobViewModel
|
||||
var query = _context.Jobs.Where(x => x.id == 10 || jobIds.Contains(x.id)).Select(x => new JobViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
JobName = x.JobName,
|
||||
@@ -181,6 +176,6 @@ public class JobRepository: RepositoryBase<long, Job>, IJobRepository
|
||||
}).Take(100).ToList();
|
||||
return jobViewModelList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.ClassificationScheme;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.Job;
|
||||
using CompanyManagment.App.Contracts.PaymentInstrument;
|
||||
using CompanyManagment.Application;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -13,12 +14,13 @@ public class ClassificationSchemeController : AdminBaseController
|
||||
{
|
||||
private readonly IClassificationSchemeApplication _classificationSchemeApplication;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
private readonly IJobApplication _jobApplication;
|
||||
|
||||
public ClassificationSchemeController(IClassificationSchemeApplication classificationSchemeApplication, IAuthHelper authHelper)
|
||||
public ClassificationSchemeController(IClassificationSchemeApplication classificationSchemeApplication, IAuthHelper authHelper, IJobApplication jobApplication)
|
||||
{
|
||||
_classificationSchemeApplication = classificationSchemeApplication;
|
||||
_authHelper = authHelper;
|
||||
_jobApplication = jobApplication;
|
||||
}
|
||||
|
||||
#region SchemeTab
|
||||
@@ -123,6 +125,17 @@ public class ClassificationSchemeController : AdminBaseController
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// سلکت لیست مشاغل
|
||||
/// </summary>
|
||||
/// <param name="searchJob"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("JobSelectList")]
|
||||
public async Task<List<JobListDto>> GetJobSelectList(string searchJob)
|
||||
{
|
||||
return await _jobApplication.JobSearchSelect(searchJob);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// چک میکند که آیا امکان حذف شغل از گروه وجود دارد
|
||||
/// </summary>
|
||||
|
||||
@@ -154,14 +154,7 @@ public class ClassificationSchemeModel : PageModel
|
||||
{
|
||||
var jobs = _jobApplication.JobSearchSelect(textSearch).GetAwaiter().GetResult();
|
||||
|
||||
jobs = jobs.OrderBy(x => x.JobName.Length).ToList().Select(x => new JobViewModel
|
||||
{
|
||||
Id = x.Id,
|
||||
JobName = x.JobName,
|
||||
JobCode = x.JobCode,
|
||||
SearchResultTitle = x.JobName,
|
||||
SearchResultCode = x.JobCode
|
||||
}).ToList();
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
IsSuccedded = true,
|
||||
|
||||
Reference in New Issue
Block a user