Folo
Folo
CC#
Created by Folo on 1/18/2024 in #help
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?
5 replies
CC#
Created by Folo on 12/7/2023 in #help
C# development on linux
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?
5 replies