The following code results in a error show by the IDE in the return's lines. This code is: csharp(CS0103) El nombre 'StatusCode' no existe en el contexto actual [DatingApp.API]csharp(CS0103) The name 'StatusCode' does not exists in the current context
I'm using .NET 3.0 and the methods BadRequest and StatusCode seem to be correct and a part of the API.
Any clue of what could be going wrong?
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Core;
using DatingApp.API.Data;
using System.Threading.Tasks;
using DatingApp.API.Models;
namespace DatingApp.API.Controllers
{
[Route("/api/[Controller]")]
[ApiController]
public class AuthController
{
private readonly IAuthRepository _repo;
public AuthController(IAuthRepository repo)
{
_repo = repo;
}
[HttpPost("register")]
public async Task<IActionResult> Register(string username, string password)
{
username = username.ToLower();
if (await _repo.UserExists(username)){
return BadRequest("Nombre de usuario ya existente");
}
var userToCreate = new User
{
Username = username
};
var createdUser = await _repo.Register(userToCreate, password);
return StatusCode(201);
}
}
}