I need some help figuring out how I can get entities by name in this setup:
// get: /api/v1/users/
[HttpGet]
public virtual async Task<IActionResult> Get()
{
var items = await service.GetAll();
if (!items.Any()) return NotFound();
return Ok(items);
}
// get: /api/v1/users/{id}
[HttpGet("{id}")]
public virtual async Task<IActionResult> Get(int id)
{
var item = await service.Get(id);
if (item == null) return NotFound();
return Ok(item);
}
// get: /api/v1/users/?name={name}
[HttpGet("{name}")]
public virtual async Task<IActionResult> Get([FromQuery]string name)
{
var item = await service.GetByUserId(name);
if (item == null) return NotFound();
return Ok(item);
}
Get() and Get(int id) workes but when I call https://xxx/api/v1/users/?name=foo the Get() method is hit and all entities are returned. How can I get entities by name?