feat: implement "GetNotCreatedWorkshop" method and update related functionality in InsuranceList
This commit is contained in:
@@ -5,14 +5,14 @@ namespace _0_Framework.InfraStructure;
|
||||
|
||||
public static class QueryableExtensions
|
||||
{
|
||||
public static IQueryable<T> ApplyPagination<T>(this IQueryable<T> query, int page, int pageSize)
|
||||
public static IQueryable<T> ApplyPagination<T>(this IQueryable<T> query, int page, int pageSize = 30)
|
||||
{
|
||||
if (page <= 0) page = 1;
|
||||
if (pageSize <= 0) pageSize = 10;
|
||||
|
||||
return query.Skip((page - 1) * pageSize).Take(pageSize);
|
||||
}
|
||||
public static IEnumerable<T> ApplyPagination<T>(this IEnumerable<T> source, int page, int pageSize)
|
||||
public static IEnumerable<T> ApplyPagination<T>(this IEnumerable<T> source, int page, int pageSize = 30)
|
||||
{
|
||||
if (page <= 0) page = 1;
|
||||
if (pageSize <= 0) pageSize = 10;
|
||||
|
||||
@@ -68,7 +68,7 @@ public interface IInsuranceListRepository:IRepository<long, InsuranceList>
|
||||
|
||||
#endregion
|
||||
|
||||
Task<InsuranceListViewModel> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel);
|
||||
Task<List<InsuranceListViewModel>> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -49,5 +49,5 @@ public interface IInsuranceListApplication
|
||||
|
||||
#endregion
|
||||
|
||||
Task<InsuranceListViewModel> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel);
|
||||
Task<List<InsuranceListViewModel>> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel);
|
||||
}
|
||||
@@ -2366,7 +2366,7 @@ public class InsuranceListApplication : IInsuranceListApplication
|
||||
return _insuranceListRepositpry.GetTabCounts(searchModel);
|
||||
}
|
||||
|
||||
public async Task<InsuranceListViewModel> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel)
|
||||
public async Task<List<InsuranceListViewModel>> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel)
|
||||
{
|
||||
return await _insuranceListRepositpry.GetNotCreatedWorkshop(searchModel);
|
||||
}
|
||||
|
||||
@@ -1473,6 +1473,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
|
||||
var workshopIds = _context.WorkshopAccounts
|
||||
.Where(a => a.AccountId == acountId)
|
||||
.Select(a => a.WorkshopId);
|
||||
|
||||
var query = _context.InsuranceListSet
|
||||
.Where(x => workshopIds.Contains(x.WorkshopId))
|
||||
.Join(_context.Workshops.Include(x => x.InsuranceWorkshopInfo),
|
||||
@@ -1569,9 +1570,56 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
|
||||
|
||||
}
|
||||
|
||||
public Task<InsuranceListViewModel> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel)
|
||||
public async Task<List<InsuranceListViewModel>> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (string.IsNullOrEmpty(searchModel.Month) || string.IsNullOrEmpty(searchModel.Year) )
|
||||
{
|
||||
return [];
|
||||
}
|
||||
var acountId = _authHelper.CurrentAccountId();
|
||||
var accountWorkshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == acountId)
|
||||
.Select(x => x.WorkshopId);
|
||||
|
||||
var insuranceWorkshops = _context.Workshops
|
||||
.Where(x=>x.InsuranceCode != null && x.InsuranceCode.Length >=10 && accountWorkshopIds.Contains(x.id) && x.IsActiveString== "true");
|
||||
|
||||
|
||||
var existInsurances = _context.InsuranceListSet
|
||||
.Where(x=>x.Month == searchModel.Month&& x.Year == searchModel.Year).AsQueryable();
|
||||
|
||||
var notCreatedWorkshop = insuranceWorkshops.Where(w=>!existInsurances.Select(x=>x.WorkshopId).Contains(w.id));
|
||||
|
||||
var res = await notCreatedWorkshop
|
||||
.GroupJoin(_context.WorkshopEmployers,
|
||||
workshop => workshop.id,
|
||||
workshopEmployer => workshopEmployer.WorkshopId,
|
||||
(workshop, workshopEmployer) => new { workshop, workshopEmployer })
|
||||
.SelectMany(x => x.workshopEmployer.DefaultIfEmpty(), (x, workshopEmployer) => new { x.workshop, workshopEmployer })
|
||||
.GroupJoin(_context.Employers,
|
||||
allResult => allResult.workshopEmployer.EmployerId,
|
||||
employer => employer.id,
|
||||
(allResult, employer) => new { allResult.workshop, allResult.workshopEmployer, employer })
|
||||
.SelectMany(x => x.employer.DefaultIfEmpty(), (x, employer) => new { x.workshop, x.workshopEmployer, employer })
|
||||
.Select(x => new InsuranceListViewModel
|
||||
{
|
||||
WorkShopId = x.workshop.id,
|
||||
WorkShopCode = x.workshop.InsuranceCode,
|
||||
WorkShopName = x.workshop.InsuranceWorkshopInfo != null ? x.workshop.InsuranceWorkshopInfo.WorkshopName : x.workshop.WorkshopFullName,
|
||||
EmployerName = x.employer != null ? x.employer.FullName : (x.workshop.InsuranceWorkshopInfo != null ? x.workshop.InsuranceWorkshopInfo.EmployerName : x.workshop.WorkshopFullName),
|
||||
Year = searchModel.Year,
|
||||
Month = searchModel.Month,
|
||||
TypeOfInsuranceSend = x.workshop.TypeOfInsuranceSend == "NormalList" ? "عادی" :
|
||||
x.workshop.TypeOfInsuranceSend == "Govermentlist" ? "کمک دولت" :
|
||||
x.workshop.TypeOfInsuranceSend == "Familylist" ? "خانوادگی" : "",
|
||||
FixedSalary = (bool)x.workshop.FixedSalary,
|
||||
StrFixedSalary = (bool)x.workshop.FixedSalary ? "دارد" : "ندارد",
|
||||
EmployerId = x.workshopEmployer != null ? x.workshopEmployer.EmployerId : 0,
|
||||
ArchiveCode = x.workshop.ArchiveCode,
|
||||
City = x.workshop.City,
|
||||
}).ApplyPagination(searchModel.PageIndex).ToListAsync();
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -544,6 +544,7 @@
|
||||
|
||||
var ajaxGetTabCountsUrl = `@Url.Page("/Company/InsuranceList/Index", "TabCounts")`;
|
||||
var ajaxSearchNewUrl = `@Url.Page("/Company/InsuranceList/Index", "SearchNew")`;
|
||||
var ajaxNotCreatedUrl = `@Url.Page("/Company/InsuranceList/Index", "NotCreatedWorkshops")`;
|
||||
var openOperationsModalUrl = `@Url.Page("/Company/InsuranceList/Index", "OperationsModal")`;
|
||||
var editUrl = `#showmodal=@Url.Page("/Company/InsuranceList/Index", "Edit")`;
|
||||
var insuranceSummaryUrl = `#showmodal=@Url.Page("/Company/InsuranceList/Index", "InsuranceSummary")`;
|
||||
|
||||
@@ -1167,7 +1167,7 @@ public class IndexModel : PageModel
|
||||
var result =await _insuranceListApplication.GetNotCreatedWorkshop(searchModel);
|
||||
return new JsonResult(new
|
||||
{
|
||||
result
|
||||
data = result
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ $(document).ready(function () {
|
||||
});
|
||||
function loadNotCreatedData() {
|
||||
var pageIndex = pageIndexJs;
|
||||
|
||||
|
||||
var html = "";
|
||||
var htmlMobile = "";
|
||||
|
||||
@@ -151,17 +151,17 @@ $(document).ready(function () {
|
||||
//Branch: paramsUrl['branch'],
|
||||
//City: paramsUrl['city'],
|
||||
FixedSalary: paramsUrl['fixed-salary'],
|
||||
Status: status,
|
||||
PageIndex: pageIndex
|
||||
};
|
||||
|
||||
var b = pageIndexJs % 30;
|
||||
|
||||
if (b === 0 && hasMoreData) {
|
||||
ajaxService.get(ajaxSearchNewUrl, searchModel, false)
|
||||
ajaxService.get(ajaxNotCreatedUrl, searchModel, false)
|
||||
.then(response => {
|
||||
var responseData = response.data;
|
||||
|
||||
debugger;
|
||||
if (responseData.length > 0) {
|
||||
responseData.forEach(function (item) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user