43 lines
1.7 KiB
C#
43 lines
1.7 KiB
C#
using Marco.Pms.Model.Dtos.PurchaseInvoice;
|
|
using Marco.Pms.Services.Service.ServiceInterfaces;
|
|
using MarcoBMS.Services.Helpers;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Marco.Pms.Services.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class PurchaseInvoiceController : ControllerBase
|
|
{
|
|
private readonly UserHelper _userHelper;
|
|
private readonly IPurchaseInvoiceService _purchaseInvoiceService;
|
|
private readonly Guid tenantId;
|
|
|
|
public PurchaseInvoiceController(UserHelper userHelper, IPurchaseInvoiceService purchaseInvoiceService)
|
|
{
|
|
_userHelper = userHelper;
|
|
_purchaseInvoiceService = purchaseInvoiceService;
|
|
tenantId = _userHelper.GetTenantId();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a purchase invoice.
|
|
/// </summary>
|
|
/// <param name="model">The purchase invoice model.</param>
|
|
/// <param name="ct">The cancellation token.</param>
|
|
/// <returns>The HTTP response with the purchase invoice status and data.</returns>
|
|
[HttpPost("create")]
|
|
public async Task<IActionResult> CreatePurchaseInvoice([FromBody] PurchaseInvoiceDto model, CancellationToken ct)
|
|
{
|
|
// Get the currently logged-in employee
|
|
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
|
|
|
// Create a purchase invoice using the purchase invoice service
|
|
var response = await _purchaseInvoiceService.CreatePurchaseInvoiceAsync(model, loggedInEmployee, tenantId, ct);
|
|
|
|
// Return the HTTP response with the purchase invoice status and data
|
|
return StatusCode(response.StatusCode, response);
|
|
}
|
|
}
|
|
}
|