I have a simple Api function:
// POST: api/Cultivation/Sow/1/5
[HttpGet("Sow/{grain}/{id}")]
public IActionResult Sow(Grain grain, int id) { }
My enum looks like this:
public enum Grain
{
None,
Rice,
Corn,
Oats
}
My question is, is it possible to get Grain
or any enum from Route? When Yes, how to do it?
If No, how to "find" enum by int in elegant way, without if statements etc? Because if myWebapi cant take enums
, it is easy to do by simple int