-1
I am one creating an api using Asp.Net that performs task listings and these tasks are displayed per day, week, month and year, my doubt is on how to perform this call only for the current week that I am, I am not able to do this way below, I would like help.
[HttpGet("filter/week/{macAddress}")]
public async Task<IActionResult> Week(string macAddress)
{
try
{
var result = await _repo.GetTodosItens(macAddress);
var week = result.AsQueryable<TaskModel>().Where(t => t.When.DayOfWeek == DateTime.Now.DayOfWeek);
return Ok(week);
}
catch (Exception ex)
{
return BadRequest($"Erro: {ex.Message}");
}
}
What is returned by doing it this way? ( What you expected/ What you get)
– Neto Costa
If you’re gonna do the
DayOfWeek
on both sides, can use only theDay
. You’re probably having trouble converting this to SQL.– Jéf Bueno