43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
|
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
using public_valetax.DTOs;
|
||
|
|
using public_valetax.Exceptions;
|
||
|
|
using public_valetax.Repositories;
|
||
|
|
|
||
|
|
namespace public_valetax.Controllers
|
||
|
|
{
|
||
|
|
[ApiController]
|
||
|
|
[Route("api.[controller]")]
|
||
|
|
public class JournalController(IJournalRepository _journalRepository) : ControllerBase
|
||
|
|
{
|
||
|
|
[HttpPost("getRange")]
|
||
|
|
public async Task<ActionResult<MRange_MJournalInfo>> GetRange([FromQuery] int skip, [FromQuery] int take, [FromBody] VJournalFilter filter)
|
||
|
|
{
|
||
|
|
var result = await _journalRepository.GetJournalEntriesRangeAsync(skip, take, filter);
|
||
|
|
return Ok(result);
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpPost("getSingle")]
|
||
|
|
public async Task<ActionResult<MJournal?>> GetSingle([FromQuery] long id)
|
||
|
|
{
|
||
|
|
var result = await _journalRepository.GetJournalEntryAsync(id);
|
||
|
|
if (result == null)
|
||
|
|
{
|
||
|
|
return NotFound();
|
||
|
|
}
|
||
|
|
return Ok(result);
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpPost("simulateError")]
|
||
|
|
public void SimulateError([FromQuery] bool isSecureException, [FromBody] Dictionary<string, object> someBody)
|
||
|
|
{
|
||
|
|
if (isSecureException)
|
||
|
|
{
|
||
|
|
throw new SecureException("Some secure error happened");
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
throw new InvalidOperationException("Some error happened");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|