-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProducersController.cs
More file actions
41 lines (39 loc) · 1.24 KB
/
Copy pathProducersController.cs
File metadata and controls
41 lines (39 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using CheersDb.Api.Dtos;
using CheersDb.Api.Http;
using Microsoft.AspNetCore.Mvc;
using System.Net.Mime;
namespace CheersDb.Api.Controllers;
/// <summary>
/// Controller for managing producers in the CheersDb API.
/// </summary>
[ApiController]
[Route("[controller]")]
[Produces(MediaTypeNames.Application.Json)]
public class ProducersController : ControllerBase
{
/// <summary>
/// Retrieves details for a specific producer by id
/// </summary>
/// <param name="id">The id of the producer to retrieve</param>
/// <returns>The requested producer details</returns>
[HttpGet("{id:int}", Name = nameof(GetProducerDetails))]
[ProducesResponseType(typeof(GetProducerDetailsDto), StatusCodes.Status200OK, Description = "Returns the requested producer in the response body")]
[ProducesResponseType(StatusCodes.Status404NotFound, Description = "Indicates the requested producer was not found, or the URI is invalid")]
public IActionResult GetProducerDetails([FromRoute] int id)
{
return Ok(new GetProducerDetailsDto()
{
Id = id,
Name = "Producer Name",
Links =
[
new()
{
Rel = LinkRels.Self,
Href = Url.RouteUrl(nameof(GetProducerDetails), new { id }) ?? string.Empty,
Method = HttpMethod.Get.ToString()
}
]
});
}
}