167 lines
5.3 KiB
C#
167 lines
5.3 KiB
C#
using System.Diagnostics;
|
|
using _0_Framework.Application;
|
|
using CompanyManagment.App.Contracts.PersonalContractingParty;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using ServiceHost.BaseControllers;
|
|
|
|
namespace ServiceHost.Areas.Admin.Controllers;
|
|
|
|
public class ContractingPartyController : AdminBaseController
|
|
{
|
|
private readonly IPersonalContractingPartyApp _contractingPartyApplication;
|
|
|
|
public ContractingPartyController(IPersonalContractingPartyApp contractingPartyApplication)
|
|
{
|
|
_contractingPartyApplication = contractingPartyApplication;
|
|
}
|
|
|
|
/// <summary>
|
|
/// لیست طرف حساب
|
|
/// </summary>
|
|
/// <param name="searchModel"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<ActionResult<ICollection<ContractingPartyGetListViewModel>>> Get([FromQuery] ContractingPartyGetListSearchModel searchModel)
|
|
{
|
|
var watch = new Stopwatch();
|
|
watch.Start();
|
|
var result = await _contractingPartyApplication.GetList(searchModel);
|
|
Console.WriteLine(watch.Elapsed);
|
|
return result.ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// جزئیات طرف حساب حقیقی
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("real/{id}")]
|
|
public async Task<ActionResult<GetRealContractingPartyDetailsViewModel>> GetDetailsReal(long id)
|
|
{
|
|
var result = await _contractingPartyApplication.GetRealDetails(id);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// جزئیات طرف حساب حقوقی
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("legal/{id}")]
|
|
public async Task<ActionResult<GetLegalContractingPartyDetailsViewModel>> GetDetailsLegal(long id)
|
|
{
|
|
var result = await _contractingPartyApplication.GetLegalDetails(id);
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// ایجاد طرف حساب حقیقی
|
|
/// </summary>
|
|
/// <param name="command"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("real")]
|
|
public async Task<ActionResult<OperationResult>> CreateReal([FromBody] CreateRealContractingParty command)
|
|
{
|
|
var result = await _contractingPartyApplication.CreateReal(command);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// ایجاد طرف حساب حقوقی
|
|
/// </summary>
|
|
/// <param name="command"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("legal")]
|
|
public async Task<ActionResult<OperationResult>> CreateLegal([FromBody] CreateLegalContractingParty command)
|
|
{
|
|
var result = await _contractingPartyApplication.CreateLegal(command);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// ویرایش طرف حساب حقیقی
|
|
/// </summary>
|
|
/// <param name="command"></param>
|
|
/// <returns></returns>
|
|
[HttpPut("real")]
|
|
public ActionResult<OperationResult> EditReal([FromBody] EditRealContractingParty command)
|
|
{
|
|
var result = _contractingPartyApplication.EditRealApi(command);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// ویرایش طرف حساب حقوقی
|
|
/// </summary>
|
|
/// <param name="command"></param>
|
|
/// <returns></returns>
|
|
[HttpPut("legal")]
|
|
public ActionResult<OperationResult> EditLegal([FromBody] EditLegalContractingParty command)
|
|
{
|
|
var result = _contractingPartyApplication.EditLegal(command);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// چک کردن بلاک بودن طرف حساب با آیدی کارفرما
|
|
/// </summary>
|
|
/// <param name="employerId">آیدی کارفرما</param>
|
|
/// <returns>true - false - NotFound</returns>
|
|
[HttpGet("is_block/{employerId}")]
|
|
public ActionResult<string> IsBlockByEmployerId(long employerId)
|
|
{
|
|
var result = _contractingPartyApplication.IsBlockByEmployerId(employerId);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// گرفتن آخرین کد بایگانی کارگاه
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("last_archive_code")]
|
|
public ActionResult<int> GetLastArchiveCodeByContractingPartyId()
|
|
{
|
|
var data = _contractingPartyApplication.GetLastArchiveCode();
|
|
return data;
|
|
}
|
|
|
|
/// <summary>
|
|
/// سلکت لیست طرف حساب برای جستجو
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("selectList")]
|
|
public async Task<ActionResult<List<ContractingPartySelectListViewModel>>> GetSelectList(string search, long id)
|
|
{
|
|
return await _contractingPartyApplication.GetSelectList(search, id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// لیست شناسه ملی یا شماره ملی برای جستجوی
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("national_Code_Select_list")]
|
|
public async Task<ActionResult<List<GetContractingPartyNationalCodeOrNationalIdViewModel>>> GetNationalCodeOrNationalId()
|
|
{
|
|
return await _contractingPartyApplication.GetNationalCodeOrNationalId();
|
|
}
|
|
|
|
/// <summary>
|
|
/// حذف طرف حساب. درصورت داشتن قرارداد مالی یا داشتن کارفرما، طرف حساب غیرفعال میشود
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpDelete]
|
|
public async Task<OperationResult<string>> DeleteContractingParty(long id)
|
|
{
|
|
var operationResult = await _contractingPartyApplication.Delete(id);
|
|
|
|
return operationResult;
|
|
}
|
|
|
|
|
|
|
|
} |