Non-invocable member 'NotFound' cannot be used like a method.
I am trying to make an API
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using RoBotAPI.Models;
using RoBotAPI.Services;
namespace RoBotAPI.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class UsersController
{
private readonly UsersService _usersService;
public UsersController(UsersService usersService) =>
_usersService = usersService;
[HttpGet]
public async Task<List<User>> Get() =>
await _usersService.GetAsync();
[HttpGet("{id}")]
public async Task<ActionResult<User>> Get(ulong id)
{
var user = await _usersService.GetAsync(id);
return user ?? NotFound();
}
}
}
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using RoBotAPI.Models;
using RoBotAPI.Services;
namespace RoBotAPI.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class UsersController
{
private readonly UsersService _usersService;
public UsersController(UsersService usersService) =>
_usersService = usersService;
[HttpGet]
public async Task<List<User>> Get() =>
await _usersService.GetAsync();
[HttpGet("{id}")]
public async Task<ActionResult<User>> Get(ulong id)
{
var user = await _usersService.GetAsync(id);
return user ?? NotFound();
}
}
}
and I'm getting the error in the title in the GET {id} method and NotFound() is (quite funnily) not found. Is this an error with my ASP.NET install or something I'm doing wrong?
I want to switch back to linux, but I don't know how good of an experience I'd have when writing C#.
Anyone want to share your experience, what IDE you use?