Closed JohanLarsson closed 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); } } }