DotNetAnalyzers / AspNetCoreAnalyzers

MIT License
62 stars 4 forks source link

Parameter name must match url template parameter #6

Closed JohanLarsson closed 5 years ago

JohanLarsson commented 5 years ago
namespace ValidCode
{
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.EntityFrameworkCore;

    [ApiController]
    public class OrdersController : Controller
    {
        private readonly Db db;

        public OrdersController(Db db)
        {
            this.db = db;
        }

        [HttpGet("api/orders/{id}")]
        public async Task<IActionResult> GetOrder(int notMatching)
        {
            var match = await this.db.Orders.FirstOrDefaultAsync(x => x.Id == notMatching);
            if (match == null)
            {
                return this.NotFound();
            }

            return this.Ok(match);
        }
    }
}