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> 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> 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 someBody) { if (isSecureException) { throw new SecureException("Some secure error happened"); } else { throw new InvalidOperationException("Some error happened"); } } } }