Passing DateOnly to controller
What's wrong with this snippet?
[HttpGet("ondate")]
public async Task<IActionResult> GetAppointmentsByDate([FromQuery]DateOnly date)
{
var appointments = await _appointmentDatabaseService.GetAppointmentByDate(date);
if (appointments != null)
{
return Ok(appointments);
}
return NotFound();
}
I'm using swagger, and the JSON looks like this:
{
"year": 2024,
"month": 5,
"day": 5,
"dayOfWeek": 1
}
yet I get the default(DateOnly) in my request
[HttpGet("ondate")]
public async Task<IActionResult> GetAppointmentsByDate([FromQuery]DateOnly date)
{
var appointments = await _appointmentDatabaseService.GetAppointmentByDate(date);
if (appointments != null)
{
return Ok(appointments);
}
return NotFound();
}
I'm using swagger, and the JSON looks like this:
{
"year": 2024,
"month": 5,
"day": 5,
"dayOfWeek": 1
}
yet I get the default(DateOnly) in my request