change GetList of ContractingPartyBankAccounts and add count to it
This commit is contained in:
@@ -8,7 +8,7 @@ namespace Company.Domain.ContractingPartyBankAccountsAgg;
|
||||
|
||||
public interface IContractingPartyBankAccountsRepository:IRepository<long,ContractingPartyBankAccount>
|
||||
{
|
||||
Task<OperationResult<List<GetContractingPartyBankAccountViewModel>>> GetList(ContractingPartyBankAccountSearchModel searchModel);
|
||||
Task<GetContractingPartyBankAccountViewModel> GetList(ContractingPartyBankAccountSearchModel searchModel);
|
||||
Task<OperationResult<List<string>>> ContractingPartyOrAccountHolderNameSelectList(string search, string selected);
|
||||
Task<OperationResult<List<string>>> IBanSelectList(string search, string selected);
|
||||
|
||||
|
||||
@@ -6,6 +6,16 @@ namespace CompanyManagment.App.Contracts.ContractingPartyBankAccounts;
|
||||
/// لیست اطلاعات بانکی طرف حساب
|
||||
/// </summary>
|
||||
public class GetContractingPartyBankAccountViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// تعداد
|
||||
/// </summary>
|
||||
public int Count { get; set; }
|
||||
public List<ContractingPartyBankAccountsGroupedViewModel> List { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class ContractingPartyBankAccountsGroupedViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// لیست حساب های بانکی
|
||||
@@ -27,6 +37,7 @@ public class GetContractingPartyBankAccountViewModel
|
||||
/// </summary>
|
||||
public string WorkshopName { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// حساب بانکی طرف حساب
|
||||
/// </summary>
|
||||
|
||||
@@ -24,8 +24,7 @@ public interface IContractingPartyBankAccountsApplication
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult<List<GetContractingPartyBankAccountViewModel>>> GetList(
|
||||
ContractingPartyBankAccountSearchModel searchModel);
|
||||
Task<GetContractingPartyBankAccountViewModel> GetList(ContractingPartyBankAccountSearchModel searchModel);
|
||||
|
||||
/// <summary>
|
||||
/// سلکت لیست جستجو برای نام طرف حساب / صاحب حساب
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ContractingPartyBankAccountsApplication:IContractingPartyBankAccoun
|
||||
|
||||
}
|
||||
|
||||
public async Task<OperationResult<List<GetContractingPartyBankAccountViewModel>>> GetList(
|
||||
public async Task<GetContractingPartyBankAccountViewModel> GetList(
|
||||
ContractingPartyBankAccountSearchModel searchModel)
|
||||
{
|
||||
return await _contractingPartyBankAccountsRepository.GetList(searchModel);
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ContractingPartyBankAccountsRepository : RepositoryBase<long, Contr
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<List<GetContractingPartyBankAccountViewModel>>> GetList(
|
||||
public async Task<GetContractingPartyBankAccountViewModel> GetList(
|
||||
ContractingPartyBankAccountSearchModel searchModel)
|
||||
{
|
||||
var query = _context.ContractingPartyBankAccounts.AsQueryable();
|
||||
@@ -38,38 +38,41 @@ public class ContractingPartyBankAccountsRepository : RepositoryBase<long, Contr
|
||||
.Contains(searchModel.ContractingPartyOrAccountHolderName) ||
|
||||
(x.ContractingParty.FName + " " + x.ContractingParty.LName).Contains(searchModel
|
||||
.ContractingPartyOrAccountHolderName));
|
||||
var count = await query.CountAsync();
|
||||
|
||||
var grouped = query
|
||||
.GroupBy(x => new { x.ContractingPartyId, x.ContractingParty.FName, x.ContractingParty.LName })
|
||||
.Select(g => new GetContractingPartyBankAccountViewModel()
|
||||
{
|
||||
ContractingPartyId = g.Key.ContractingPartyId,
|
||||
ContractingPartyName = g.Key.FName + " " + g.Key.LName,
|
||||
BankAccountsItems = g.Select(x => new ContractingPartyBankAccountsItemViewModel
|
||||
var result = new GetContractingPartyBankAccountViewModel()
|
||||
{
|
||||
Count = count,
|
||||
List = await query
|
||||
.GroupBy(x => new { x.ContractingPartyId, x.ContractingParty.FName, x.ContractingParty.LName })
|
||||
.Select(g => new ContractingPartyBankAccountsGroupedViewModel()
|
||||
{
|
||||
AccountHolderName = x.AccountHolderName,
|
||||
AccountNumber = x.AccountNumber,
|
||||
CardNumber = x.CardNumber,
|
||||
IBan = x.IBan,
|
||||
}).ToList()
|
||||
});
|
||||
ContractingPartyId = g.Key.ContractingPartyId,
|
||||
ContractingPartyName = g.Key.FName + " " + g.Key.LName,
|
||||
BankAccountsItems = g.Select(x => new ContractingPartyBankAccountsItemViewModel
|
||||
{
|
||||
AccountHolderName = x.AccountHolderName,
|
||||
AccountNumber = x.AccountNumber,
|
||||
CardNumber = x.CardNumber,
|
||||
IBan = x.IBan,
|
||||
}).ToList()
|
||||
}).Skip(searchModel.PageIndex)
|
||||
.Take(30).ToListAsync()
|
||||
};
|
||||
|
||||
var result = await grouped
|
||||
.Skip(searchModel.PageIndex)
|
||||
.Take(30)
|
||||
.ToListAsync();
|
||||
|
||||
return new OperationResult<List<GetContractingPartyBankAccountViewModel>>().Succcedded(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<List<string>>> ContractingPartyOrAccountHolderNameSelectList(string search,
|
||||
string selected)
|
||||
{
|
||||
var accountHolderQuery = _context.ContractingPartyBankAccounts.Select(x => x.AccountHolderName);
|
||||
var contractingPartyNameQuery = _context.ContractingPartyBankAccounts.Select(x=>x.ContractingParty.FName + " " + x.ContractingParty.LName);
|
||||
var contractingPartyNameQuery =
|
||||
_context.ContractingPartyBankAccounts.Select(x =>
|
||||
x.ContractingParty.FName + " " + x.ContractingParty.LName);
|
||||
if (!string.IsNullOrWhiteSpace(search))
|
||||
{
|
||||
accountHolderQuery = accountHolderQuery.Where(x=>x.Contains(search));
|
||||
accountHolderQuery = accountHolderQuery.Where(x => x.Contains(search));
|
||||
contractingPartyNameQuery = contractingPartyNameQuery.Where(x => x.Contains(search));
|
||||
}
|
||||
|
||||
@@ -79,13 +82,13 @@ public class ContractingPartyBankAccountsRepository : RepositoryBase<long, Contr
|
||||
{
|
||||
result.Add(selected);
|
||||
}
|
||||
|
||||
|
||||
return new OperationResult<List<string>>().Succcedded(result.Distinct().ToList());
|
||||
}
|
||||
|
||||
public async Task<OperationResult<List<string>>> IBanSelectList(string search, string selected)
|
||||
{
|
||||
var iBanQuery = _context.ContractingPartyBankAccounts.Select(x=>x.IBan);
|
||||
var iBanQuery = _context.ContractingPartyBankAccounts.Select(x => x.IBan);
|
||||
if (!string.IsNullOrWhiteSpace(search))
|
||||
{
|
||||
iBanQuery = iBanQuery.Where(x => x.Contains(search));
|
||||
@@ -97,13 +100,13 @@ public class ContractingPartyBankAccountsRepository : RepositoryBase<long, Contr
|
||||
{
|
||||
result.Add(selected);
|
||||
}
|
||||
|
||||
|
||||
return new OperationResult<List<string>>().Succcedded(result.Distinct().ToList());
|
||||
}
|
||||
|
||||
public async Task<OperationResult<List<string>>> CardNumberSelectList(string search, string selected)
|
||||
{
|
||||
var cardNumberQuery = _context.ContractingPartyBankAccounts.Select(x=>x.CardNumber);
|
||||
var cardNumberQuery = _context.ContractingPartyBankAccounts.Select(x => x.CardNumber);
|
||||
if (!string.IsNullOrWhiteSpace(search))
|
||||
{
|
||||
cardNumberQuery = cardNumberQuery.Where(x => x.Contains(search));
|
||||
@@ -115,13 +118,13 @@ public class ContractingPartyBankAccountsRepository : RepositoryBase<long, Contr
|
||||
{
|
||||
result.Add(selected);
|
||||
}
|
||||
|
||||
|
||||
return new OperationResult<List<string>>().Succcedded(result.Distinct().ToList());
|
||||
}
|
||||
|
||||
public async Task<OperationResult<List<string>>> AccountNumberSelectList(string search, string selected)
|
||||
{
|
||||
var accountNumberQuery = _context.ContractingPartyBankAccounts.Select(x=>x.IBan);
|
||||
var accountNumberQuery = _context.ContractingPartyBankAccounts.Select(x => x.IBan);
|
||||
if (!string.IsNullOrWhiteSpace(search))
|
||||
{
|
||||
accountNumberQuery = accountNumberQuery.Where(x => x.Contains(search));
|
||||
@@ -133,7 +136,7 @@ public class ContractingPartyBankAccountsRepository : RepositoryBase<long, Contr
|
||||
{
|
||||
result.Add(selected);
|
||||
}
|
||||
|
||||
|
||||
return new OperationResult<List<string>>().Succcedded(result.Distinct().ToList());
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class ContractingPartyBankAccountController : AdminBaseController
|
||||
/// <param name="searchModel">سرچ</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<OperationResult<List<GetContractingPartyBankAccountViewModel>>> GetList(ContractingPartyBankAccountSearchModel searchModel)
|
||||
public async Task<GetContractingPartyBankAccountViewModel> GetList(ContractingPartyBankAccountSearchModel searchModel)
|
||||
{
|
||||
var res =await _contractingPartyBankAccountsApplication.GetList(searchModel);
|
||||
return res;
|
||||
|
||||
Reference in New Issue
Block a user