Take a look at the code from this site: https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-2.2&tabs=visual-studio
In GET method one can see (code). Function filter over id: aip/Todo/5. How can I create a method (in order to use HttpGet) but to filter over another parameter like "name"?
// GET: api/Todo
[HttpGet]
public async Task<ActionResult<IEnumerable<TodoItem>>> GetTodoItems()
{
return await _context.TodoItems.ToListAsync();
}
// GET: api/Todo/5
[HttpGet("{id}")]
public async Task<ActionResult<TodoItem>> GetTodoItem(long id)
{
var todoItem = await _context.TodoItems.FindAsync(id);
if (todoItem == null)
{
return NotFound();
}
return todoItem;
}
In the example we have:
namespace TodoApi.Models
{
public class TodoItem
{
public long Id { get; set; }
public string Name { get; set; }
public bool IsComplete { get; set; }
}
}
So what I want I want to have 3 functions: // GET: api/Todo/5 [HttpGet("{id}")]
one to filter over Id, another one to filter over Name and another one to filter over IsComplete.
How can I do that?