add BankController and methods for retrieving bank list; update EmployeeBankInfoController with Excel download functionality

This commit is contained in:
2026-02-02 10:22:34 +03:30
parent 8faddedd46
commit fedfc372d0
7 changed files with 86 additions and 5 deletions

View File

@@ -8,5 +8,6 @@ namespace Company.Domain.BankAgg
{
public void Remove(Bank entity);
List<BankViewModel> Search(string name);
List<BankSelectList> GetBanksForSelectList();
}
}

View File

@@ -10,5 +10,12 @@ namespace CompanyManagment.App.Contracts.Bank
OperationResult Create(CreateBank command);
OperationResult Edit(EditBank command);
List<BankViewModel> Search(string name);
List<BankSelectList> GetBanksForSelectList();
}
public class BankSelectList:SelectListViewModel
{
}
}

View File

@@ -104,5 +104,10 @@ namespace CompanyManagment.Application
Id = x.Id
}).ToList();
}
public List<BankSelectList> GetBanksForSelectList()
{
return _bankRepository.GetBanksForSelectList();
}
}
}

View File

@@ -31,4 +31,13 @@ public class BankRepository:RepositoryBase<long,Bank>,IBankRepository
BankLogoPictureMediaId = x.BankLogoMediaId
}).ToList();
}
public List<BankSelectList> GetBanksForSelectList()
{
return context.Banks.Select(x => new BankSelectList()
{
Id = x.id,
Text = x.BankName
}).ToList();
}
}

View File

@@ -1,5 +1,6 @@
using _0_Framework.Application;
using CompanyManagment.App.Contracts.EmployeeBankInformation;
using CompanyManagement.Infrastructure.Excel.EmployeeBankInfo;
using Microsoft.AspNetCore.Mvc;
using ServiceHost.BaseControllers;
@@ -30,20 +31,51 @@ public class EmployeeBankInfoController : ClientBaseController
return await _employeeBankInformationApplication.GetDetailsByEmployeeIdAsync(_workshopId, employeeId);
}
public ActionResult<OperationResult> Create(CreateEmployeeInformation command)
[HttpPost]
public ActionResult<OperationResult> Create([FromBody]CreateEmployeeInformation command)
{
command.WorkshopId = _workshopId;
return _employeeBankInformationApplication.Create(command);
}
public ActionResult<OperationResult> Edit(EditEmployeeInformation command)
[HttpPut]
public ActionResult<OperationResult> Edit([FromBody]EditEmployeeInformation command)
{
command.WorkshopId = _workshopId;
return _employeeBankInformationApplication.Edit(command);
}
public ActionResult<OperationResult> Remove(long id)
[HttpDelete]
public ActionResult<OperationResult> Remove([FromQuery]long id)
{
return _employeeBankInformationApplication.Remove(id);
}
[HttpPost]
public ActionResult DownloadExcel([FromBody]DownloadExcelRequest request)
{
var employeeBankInformationViewModelForExcels = _employeeBankInformationApplication.SearchForExcel(_workshopId,
new EmployeeBankInformationSearchModel() { EmployeeBankInfoIds = request.Ids });
var resultViewModel = employeeBankInformationViewModelForExcels.Select(x => new EmployeeBankInfoExcelViewModel
{
Name = x.EmployeeName,
BankAccounts = x.BankInformationList.Select(b => new BankInfoExcelViewModel()
{
IsDefault = b.IsDefault,
ShebaNumber = b.ShebaNumber,
AccountNumber = b.BankAccountNumber,
BankName = b.BankName,
CardNumber = b.CardNumber
}).ToList()
}).ToList();
var bytes = EmployeeBankInfoExcelGenerator.Generate(resultViewModel);
return File(bytes,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
$"اطلاعات بانکی پرسنل.xlsx");
}
}
public class DownloadExcelRequest
{
public List<long> Ids { get; set; }
}

View File

@@ -8,6 +8,8 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Security.Claims;
using CompanyManagement.Infrastructure.Excel.EmployeeBankInfo;
using CompanyManagment.App.Contracts.Bank;
using CompanyManagement.Infrastructure.Excel.EmployeeBankInfo;
namespace ServiceHost.Areas.Client.Pages.Company.EmployeesBankInfo
{

View File

@@ -0,0 +1,25 @@
using CompanyManagment.App.Contracts.Bank;
using Microsoft.AspNetCore.Mvc;
using ServiceHost.BaseControllers;
namespace ServiceHost.Controllers;
public class BankController : GeneralBaseController
{
private readonly IBankApplication _bankApplication;
public BankController(IBankApplication bankApplication)
{
_bankApplication = bankApplication;
}
/// <summary>
/// دریافت لیست بانک‌ها برای SelectList
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult<List<BankSelectList>> GetBankList()
{
return _bankApplication.GetBanksForSelectList();
}
}