You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Threading.Tasks; |
|
using Microsoft.AspNetCore.Http; |
|
using Microsoft.AspNetCore.Mvc; |
|
using scraper.Models.Itinerary; |
|
using Server.Services.Interfaces; |
|
|
|
namespace Server.Controllers.V3; |
|
|
|
[ApiController] |
|
[ApiExplorerSettings(GroupName = "v3")] |
|
[Route("/v3/[controller]")] |
|
public class ItinerariesController : Controller { |
|
private IDataManager DataManager { get; } |
|
private IDatabase Database { get; } |
|
|
|
public ItinerariesController(IDataManager dataManager, IDatabase database) { |
|
this.DataManager = dataManager; |
|
this.Database = database; |
|
} |
|
|
|
|
|
[HttpGet("")] |
|
[ProducesResponseType(typeof(IEnumerable<IItinerary>), StatusCodes.Status200OK)] |
|
[ProducesResponseType(StatusCodes.Status404NotFound)] |
|
public async Task<ActionResult<IEnumerable<IItinerary>>> FindItineraries( |
|
[FromQuery] string from, |
|
[FromQuery] string to, |
|
[FromQuery] DateTimeOffset? date |
|
) { |
|
var itineraries = await DataManager.FetchItineraries(from, to, date); |
|
|
|
if (itineraries == null) { |
|
return NotFound(); |
|
} |
|
|
|
return Ok(itineraries); |
|
} |
|
} |