46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using Expose.MyIT.Shared.Models.Stateless;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Expose.MyIT.Server.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class SsaOrderController : ControllerBase, ISsaOrderController<ActionResult>
|
|
{
|
|
|
|
private readonly ISsaOrderRepository _SsaOrderRepository;
|
|
|
|
public SsaOrderController(ISsaOrderRepository SsaOrderRepository) => _SsaOrderRepository = SsaOrderRepository;
|
|
|
|
[HttpGet(nameof(ISsaOrderController<ActionResult>.Action.All))]
|
|
public async Task<ActionResult> GetAllSsaOrders()
|
|
{
|
|
try
|
|
{
|
|
Shared.ViewModels.SsaOrder[] results = await _SsaOrderRepository.GetAllSsaOrders();
|
|
return Ok(results);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError,
|
|
"Error retrieving data from the database");
|
|
}
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("{id}")]
|
|
public async Task<ActionResult> GetSsaOrders(string id)
|
|
{
|
|
try
|
|
{
|
|
Shared.ViewModels.SsaOrder[] results = await _SsaOrderRepository.GetSsaOrders(id);
|
|
return Ok(results);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError,
|
|
"Error retrieving data from the database");
|
|
}
|
|
}
|
|
|
|
} |