mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-09-30 10:03:14 +00:00
38 lines
1 KiB
C#
38 lines
1 KiB
C#
|
|
using Microsoft.AspNetCore.Authorization;
|
||
|
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
using ProposalSystem.Application.DTOs;
|
||
|
|
using ProposalSystem.Application.Interfaces;
|
||
|
|
|
||
|
|
namespace ProposalSystem.Api.Controllers;
|
||
|
|
|
||
|
|
[ApiController]
|
||
|
|
[Route("api/customers")]
|
||
|
|
[Authorize]
|
||
|
|
public class CustomersController : ControllerBase
|
||
|
|
{
|
||
|
|
private readonly ICustomerService _customerService;
|
||
|
|
|
||
|
|
public CustomersController(ICustomerService customerService)
|
||
|
|
{
|
||
|
|
_customerService = customerService;
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpGet]
|
||
|
|
public async Task<ActionResult<IReadOnlyList<CustomerResponse>>> Search(
|
||
|
|
[FromQuery] string? query,
|
||
|
|
CancellationToken ct)
|
||
|
|
{
|
||
|
|
var result = await _customerService.SearchAsync(query, ct);
|
||
|
|
return Ok(result);
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpPost]
|
||
|
|
public async Task<ActionResult<CustomerResponse>> Create(
|
||
|
|
[FromBody] CreateCustomerRequest request,
|
||
|
|
CancellationToken ct)
|
||
|
|
{
|
||
|
|
var result = await _customerService.CreateAsync(request, ct);
|
||
|
|
return Created($"/api/customers/{result.Id}", result);
|
||
|
|
}
|
||
|
|
}
|