This commit is contained in:
syntax24
2025-07-19 18:26:02 +03:30
5 changed files with 103 additions and 95 deletions

View File

@@ -53,8 +53,9 @@ public interface IPersonalContractingPartyRepository :IRepository<long, Personal
/// <summary>
/// لیست طرف حساب برای سلکت لیست سرچ
/// </summary>
/// <param name="search"></param>
/// <returns></returns>
Task<List<ContractingPartySelectListViewModel>> GetSelectList();
Task<List<ContractingPartySelectListViewModel>> GetSelectList(string search);
/// <summary>
/// لیستی از شماره ملی یا شناسه ملی بر اساس حقیقی یا حقوقی بودن

View File

@@ -67,8 +67,9 @@ public interface IPersonalContractingPartyApp
/// <summary>
/// لیست طرف حساب برای سلکت لیست سرچ
/// </summary>
/// <param name="search"></param>
/// <returns></returns>
Task<List<ContractingPartySelectListViewModel>> GetSelectList();
Task<List<ContractingPartySelectListViewModel>> GetSelectList(string search);
/// <summary>
/// ایجاد طرف حساب حقیقی

View File

@@ -518,9 +518,9 @@ public class PersonalContractingPartyApplication : IPersonalContractingPartyApp
return await _personalContractingPartyRepository.GetList(searchModel);
}
public async Task<List<ContractingPartySelectListViewModel>> GetSelectList()
public async Task<List<ContractingPartySelectListViewModel>> GetSelectList(string search)
{
return await _personalContractingPartyRepository.GetSelectList();
return await _personalContractingPartyRepository.GetSelectList(search);
}
public async Task<OperationResult> CreateReal(CreateRealContractingParty command)
{

View File

@@ -41,7 +41,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
IsLegal = x.IsLegal,
//Phone = x.Phone,
//AgentPhone = x.AgentPhone,
}).ToList();
res = res.Select(x => new PersonalContractingPartyViewModel()
@@ -51,7 +51,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
FName = x.FName,
LName = !string.IsNullOrWhiteSpace(x.SureName) ? $"{x.LName} ({x.SureName})" : $"{x.LName}",
SureName = x.SureName,
FullName = !string.IsNullOrWhiteSpace(x.SureName) ? (x.LName+" "+ x.SureName) : $"{x.LName}",
FullName = !string.IsNullOrWhiteSpace(x.SureName) ? (x.LName + " " + x.SureName) : $"{x.LName}",
//Nationalcode = x.Nationalcode,
//IdNumber = x.IdNumber,
//RegisterId = x.RegisterId,
@@ -74,32 +74,32 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
public EditPersonalContractingParty GetDetails(long id)
{
var res = _context.PersonalContractingParties.Select(x => new EditPersonalContractingParty()
{
Id = x.id,
FName = x.FName,
LName = x.IsLegal == "حقیقی" ? $"{x.FName} {x.LName}" : $"{x.LName}",
SureName = x.SureName,
Nationalcode = x.Nationalcode,
IdNumber = x.IdNumber,
RegisterId = x.RegisterId,
NationalId = x.NationalId,
IsLegal = x.IsLegal,
Phone = x.Phone,
AgentPhone = x.AgentPhone,
Address = x.Address,
ArchiveCode = x.ArchiveCode,
RepresentativeId = x.RepresentativeId,
RepresentativeFullName = x.RepresentativeFullName,
State = x.State,
City = x.City,
Zone = x.Zone,
IsActiveString = x.IsActiveString,
IsBlock = x.IsBlock,
BlockTimes = x.BlockTimes,
{
Id = x.id,
FName = x.FName,
LName = x.IsLegal == "حقیقی" ? $"{x.FName} {x.LName}" : $"{x.LName}",
SureName = x.SureName,
Nationalcode = x.Nationalcode,
IdNumber = x.IdNumber,
RegisterId = x.RegisterId,
NationalId = x.NationalId,
IsLegal = x.IsLegal,
Phone = x.Phone,
AgentPhone = x.AgentPhone,
Address = x.Address,
ArchiveCode = x.ArchiveCode,
RepresentativeId = x.RepresentativeId,
RepresentativeFullName = x.RepresentativeFullName,
State = x.State,
City = x.City,
Zone = x.Zone,
IsActiveString = x.IsActiveString,
IsBlock = x.IsBlock,
BlockTimes = x.BlockTimes,
})
})
.FirstOrDefault(x => x.Id == id);
if (res != null)
@@ -112,32 +112,32 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
public EditPersonalContractingParty GetDetailsToEdit(long id)
{
return _context.PersonalContractingParties.Select(x => new EditPersonalContractingParty()
{
Id = x.id,
{
Id = x.id,
FName = x.FName,
LName = x.LName,
SureName = x.SureName,
Nationalcode = x.Nationalcode,
IdNumber = x.IdNumber,
RegisterId = x.RegisterId,
NationalId = x.NationalId,
IsLegal = x.IsLegal,
Phone = x.Phone,
AgentPhone = x.AgentPhone,
Address = x.Address,
ArchiveCode = x.ArchiveCode,
RepresentativeId = x.RepresentativeId,
RepresentativeFullName = x.RepresentativeFullName,
State = x.State,
City = x.City,
Zone = x.Zone,
IsActiveString = x.IsActiveString,
IsBlock = x.IsBlock,
BlockTimes = x.BlockTimes,
FName = x.FName,
LName = x.LName,
SureName = x.SureName,
Nationalcode = x.Nationalcode,
IdNumber = x.IdNumber,
RegisterId = x.RegisterId,
NationalId = x.NationalId,
IsLegal = x.IsLegal,
Phone = x.Phone,
AgentPhone = x.AgentPhone,
Address = x.Address,
ArchiveCode = x.ArchiveCode,
RepresentativeId = x.RepresentativeId,
RepresentativeFullName = x.RepresentativeFullName,
State = x.State,
City = x.City,
Zone = x.Zone,
IsActiveString = x.IsActiveString,
IsBlock = x.IsBlock,
BlockTimes = x.BlockTimes,
})
})
.FirstOrDefault(x => x.Id == id);
}
@@ -154,7 +154,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
}).FirstOrDefault(x => x.id == id);
if (res != null)
{
@@ -167,8 +167,8 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
{
return "";
}
}
@@ -177,7 +177,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
var query = _context.PersonalContractingParties.Select(x => new PersonalContractingPartyViewModel
{
id = x.id,
FName = x.FName,
LName = !string.IsNullOrWhiteSpace(x.SureName) ? $"{x.LName} ({x.SureName})" : $"{x.LName}",
SureName = x.SureName,
@@ -224,7 +224,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
if (res > 0)
{
res += 1;
return res;
}
@@ -237,13 +237,13 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
#region Mahan
public List<string> SearchByName(string name)
{
var contractingParties = _context.PersonalContractingParties.Select(x => new PersonalContractingPartyViewModel()
{
FullName = x.IsLegal == "حقوقی" ? x.LName : $"{x.FName} {x.LName}"
}).ToList();
return contractingParties.Select(x => x.FullName).ToList();
}
{
var contractingParties = _context.PersonalContractingParties.Select(x => new PersonalContractingPartyViewModel()
{
FullName = x.IsLegal == "حقوقی" ? x.LName : $"{x.FName} {x.LName}"
}).ToList();
return contractingParties.Select(x => x.FullName).ToList();
}
public AccountViewModel GetAccountByPersonalContractingParty(long contractingPartyId)
{
@@ -268,7 +268,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
#region NewByHeydari
public List<PersonalContractingPartyViewModel> GetPersonalContractingPartiesForNationalcode(string searchText)
{
var result = _context.PersonalContractingParties.Where(x => (!string.IsNullOrEmpty(x.Nationalcode) && x.Nationalcode.StartsWith(searchText)) )
var result = _context.PersonalContractingParties.Where(x => (!string.IsNullOrEmpty(x.Nationalcode) && x.Nationalcode.StartsWith(searchText)))
.Select(x => new PersonalContractingPartyViewModel
{
id = x.id,
@@ -280,7 +280,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
}
public List<PersonalContractingPartyViewModel> SearchForMain(PersonalContractingPartySearchModel searchModel2)
{
var query = _context.PersonalContractingParties.Include(x=>x.Employers).Select(x => new PersonalContractingPartyViewModel
var query = _context.PersonalContractingParties.Include(x => x.Employers).Select(x => new PersonalContractingPartyViewModel
{
id = x.id,
@@ -293,7 +293,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
NationalId = x.NationalId,
IsLegal = x.IsLegal,
ArchiveCode = x.ArchiveCode,
FullName = x.FName+ " "+x.LName,
FullName = x.FName + " " + x.LName,
State = x.State,
City = x.City,
Zone = x.Zone,
@@ -302,32 +302,32 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
BlockTimes = x.BlockTimes,
RepresentativeId = x.RepresentativeId,
CreationDate = x.CreationDate.ToString(),
EmployerList = x.Employers.Select(y => new EmployerViewModel() { Id = y.id, FullName = y.FullName}).ToList()
EmployerList = x.Employers.Select(y => new EmployerViewModel() { Id = y.id, FullName = y.FullName }).ToList()
});
if (searchModel2.id > 0)
query = query.Where(x => x.id == searchModel2.id);
if (!string.IsNullOrWhiteSpace(searchModel2.Nationalcode) && searchModel2.Nationalcode != "0")
query = query.Where(x => x.Nationalcode.Contains(searchModel2.Nationalcode));
if (searchModel2.RepresentativeId > 0)
query = query.Where(x => x.RepresentativeId== searchModel2.RepresentativeId);
query = query.Where(x => x.RepresentativeId == searchModel2.RepresentativeId);
if (!string.IsNullOrWhiteSpace(searchModel2.IsLegal))
query = query.Where(x => x.IsLegal==searchModel2.IsLegal);
query = query.Where(x => x.IsLegal == searchModel2.IsLegal);
if (!string.IsNullOrWhiteSpace(searchModel2.IsActiveString)&& searchModel2.IsActiveString!="both")
query = query.Where(x => x.IsActiveString==searchModel2.IsActiveString);
if (!string.IsNullOrWhiteSpace(searchModel2.IsActiveString) && searchModel2.IsActiveString != "both")
query = query.Where(x => x.IsActiveString == searchModel2.IsActiveString);
if (!string.IsNullOrEmpty(searchModel2.RepresentativeName))
{
var representativeIds = _context.RepresentativeSet.Where(x => !string.IsNullOrEmpty(x.FullName) && x.FullName.Contains(searchModel2.RepresentativeName)).Select(x=>x.id).ToList();
query = query.Where(x => representativeIds.Contains( x.RepresentativeId));
var representativeIds = _context.RepresentativeSet.Where(x => !string.IsNullOrEmpty(x.FullName) && x.FullName.Contains(searchModel2.RepresentativeName)).Select(x => x.id).ToList();
query = query.Where(x => representativeIds.Contains(x.RepresentativeId));
}
if (!string.IsNullOrEmpty(searchModel2.EmployeeName))
{
query = query.Where(x => (x.IsLegal == "حقیقی" &&
query = query.Where(x => (x.IsLegal == "حقیقی" &&
((!string.IsNullOrWhiteSpace(x.FName) && x.FName.StartsWith(searchModel2.EmployeeName)) ||
(!string.IsNullOrWhiteSpace(x.LName) && x.LName.StartsWith(searchModel2.EmployeeName))))
|| (x.IsLegal == "حقوقی" && (!string.IsNullOrWhiteSpace(x.LName) && x.LName.Contains(searchModel2.EmployeeName))));
@@ -351,10 +351,10 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
return op.Failed("حذف با خطا مواجه شد.");
}
}
public bool GetHasContract(long id)
}
public bool GetHasContract(long id)
{
return _context.InstitutionContractSet.Any(x =>x.IsActiveString== "true" && x.ContractingPartyId == id);
return _context.InstitutionContractSet.Any(x => x.IsActiveString == "true" && x.ContractingPartyId == id);
}
public OperationResult DeActiveAll(long id)
@@ -368,10 +368,10 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
personel.DeActive();
var employers = _context.Employers.Where(x => x.ContractingPartyId == id).ToList();
employers.ForEach(x=>x.DeActive());
employers.ForEach(x => x.DeActive());
var employerIds= employers.Select(x=>x.id).ToList();
var workshopIds=_context.WorkshopEmployers.Where(x=> employerIds.Contains(x.EmployerId)).Select(x=>x.WorkshopId).ToList();
var employerIds = employers.Select(x => x.id).ToList();
var workshopIds = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId)).Select(x => x.WorkshopId).ToList();
var workshops = _context.Workshops.Where(x => workshopIds.Contains(x.id)).ToList();
workshops.ForEach(x => x.DeActive(x.ArchiveCode));
@@ -443,7 +443,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
var res = _context.PersonalContractingParties.FirstOrDefault(x => x.id == emp.ContractingPartyId);
if (res != null)
return res.IsBlock;
return $"NotFound";
}
@@ -459,14 +459,14 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
.ThenInclude(x => x.ContractingParty)
.Select(c => c.Employer.ContractingParty);
return e.Any(x => x.IsBlock == "true");
}
}
#endregion
#region ForClients
public ContractingPartyAndStatmentIdViewModel GetContractingpartyIdByAccountId(long accountId)
{
var contractingPartId = _context.ContractingPartyAccounts.Any(x => x.AccountId == accountId) ?
var contractingPartId = _context.ContractingPartyAccounts.Any(x => x.AccountId == accountId) ?
_context.ContractingPartyAccounts.FirstOrDefault(x => x.AccountId == accountId)!.PersonalContractingPartyId : 0;
var financialStatmentId = _context.FinancialStatments
.Any(x => x.ContractingPartyId == contractingPartId) ? _context.FinancialStatments
@@ -572,18 +572,24 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
return result;
}
public async Task<List<ContractingPartySelectListViewModel>> GetSelectList()
public async Task<List<ContractingPartySelectListViewModel>> GetSelectList(string search)
{
return await _context.PersonalContractingParties.Select(x => new ContractingPartySelectListViewModel
var query = _context.PersonalContractingParties.Select(x => new ContractingPartySelectListViewModel
{
Id = x.id,
Text = x.IsLegal == "حقیقی" ? x.SureName == null
? $"{x.FName} {x.LName}"
: $"{x.FName} {x.LName} {x.SureName}"
: x.SureName == null ? $"{x.LName}"
: $"{x.LName} {x.SureName}",
? x.FName + " " + x.LName
: x.FName + " " + x.LName + " " + x.SureName
: x.SureName == null ? x.LName
: x.LName + " " + x.SureName
}).ToListAsync();
});
if (!string.IsNullOrWhiteSpace(search))
{
query = query.Where(x => x.Text.Contains(search));
}
return await query.Take(100).ToListAsync();
}
public async Task<List<GetContractingPartyNationalCodeOrNationalIdViewModel>> GetNationalCodeOrNationalId()

View File

@@ -140,9 +140,9 @@ public class ContractingPartyController : AdminBaseController
/// </summary>
/// <returns></returns>
[HttpGet("selectList")]
public async Task<ActionResult<List<ContractingPartySelectListViewModel>>> GetSelectList()
public async Task<ActionResult<List<ContractingPartySelectListViewModel>>> GetSelectList(string search)
{
return await _contractingPartyApplication.GetSelectList();
return await _contractingPartyApplication.GetSelectList(search);
}
/// <summary>