- Add optional UnitId parameter to CostCyclsList method for filtering cycles by specific unit - Replace UnitIds/UnitNames lists with structured UnitInfoDto containing Id and Name - Clean unit names by removing "GUID#" prefix when present - Update CostCycleDto to use UnitInfoDto list instead of separate Id and Name lists - Fix unit assignment logic in Add and Edit methods to use new DTO structure
82 lines
3.1 KiB
C#
82 lines
3.1 KiB
C#
using Complex.Application.Services.Basic;
|
||
//using Complex.Application.Services.Transaction;
|
||
using Complex.Common.Dto;
|
||
using Microsoft.AspNetCore.Authorization;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
|
||
namespace Complex.EndPoint.Controllers
|
||
{
|
||
/// <summary>
|
||
/// مدیریت شارژ
|
||
/// </summary>
|
||
[ApiController]
|
||
[ApiVersion("1")]
|
||
[Route("api/v{version:apiVersion}/[controller]/[action]")]
|
||
//[Route("[controller]/[action]")]
|
||
[Authorize]
|
||
public class ManageCostController : Controller
|
||
{
|
||
private ILogger _logger;
|
||
private CostService _costCycleService;
|
||
public ManageCostController(CostService costCycleService, ILogger<ManageCostController> logger)
|
||
{
|
||
_costCycleService = costCycleService;
|
||
_logger = logger;
|
||
}
|
||
[HttpPost]
|
||
public ResultDto<Guid> InsertCostCycle(CostCycleDto costCycleDto)
|
||
{
|
||
return _costCycleService.InsertCostCycle(costCycleDto);
|
||
}
|
||
[HttpPost]
|
||
public ResultDto<bool> EditCostCycle(CostCycleDto costCycleDto)
|
||
{
|
||
return _costCycleService.EditCostCycle(costCycleDto);
|
||
}
|
||
/// <summary>
|
||
/// لیست مدیریت شارژ یا هر گونه مخارج گرفته می شود
|
||
/// </summary>
|
||
/// <param name="ComplexId"></param>
|
||
/// <param name="StartDate"></param>
|
||
/// <param name="EndDate"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public ResultDto<List<CostCycleDto>> CostCyclsList([FromForm] Guid ComplexId, [FromForm] DateTime? StartDate = null, [FromForm] DateTime? EndDate = null, [FromForm] Guid? UnitId = null)
|
||
{
|
||
return _costCycleService.CostCyclsList(ComplexId,
|
||
!StartDate.HasValue ? null : DateOnly.FromDateTime(StartDate.Value),
|
||
!EndDate.HasValue ? null : DateOnly.FromDateTime(EndDate.Value),
|
||
UnitId: UnitId);
|
||
}
|
||
/// <summary>
|
||
/// بدهی یک واحد
|
||
/// </summary>
|
||
/// <param name="unitId"></param>
|
||
/// <param name="incomeCostTitleId"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public ResultDto<CostOfUnitInfoDto> CalculateCostForUnit(Guid unitId, int? incomeCostTitleId)
|
||
{
|
||
return _costCycleService.CalculateCostForUnit(unitId, incomeCostTitleId);
|
||
}
|
||
/// <summary>
|
||
/// لیست بدهی های یک واحد
|
||
/// </summary>
|
||
[HttpPost]
|
||
public ResultDto<List<CostOfUnitInfoDto>> CalculateAllCostForUnit(List<Guid> unitIds)
|
||
{
|
||
return _costCycleService.CalculateAllCostForUnits(unitIds);
|
||
}
|
||
/// <summary>
|
||
/// تاریخچه پرداختی ها و باقیمانده از آن
|
||
/// </summary>
|
||
[HttpPost]
|
||
public ResultDto<List<CostOfUnitInfoDto>> CostsForUnit(List<Guid> unitIds, int? incomeCostTitleId,
|
||
DateTime startDate, DateTime endDate)
|
||
{
|
||
return _costCycleService.CostsForUnits(unitIds, incomeCostTitleId,
|
||
DateOnly.FromDateTime(startDate), DateOnly.FromDateTime(endDate));
|
||
}
|
||
}
|
||
}
|