| | | 1 | | using System.Reflection; |
| | | 2 | | using System.Text.Json; |
| | | 3 | | using Api.Extensions; |
| | | 4 | | using Application.Service; |
| | | 5 | | using Infrastructure.Entity; |
| | | 6 | | using Microsoft.AspNetCore.Mvc; |
| | | 7 | | using Microsoft.EntityFrameworkCore; |
| | | 8 | | namespace Api.Controller.v1; |
| | | 9 | | |
| | | 10 | | [ApiController] |
| | | 11 | | [Route("api/[controller]/[action]")] |
| | | 12 | | [ApiVersion("1")] |
| | | 13 | | [Produces("application/json")] |
| | | 14 | | public class ProductController : ControllerBase { |
| | | 15 | | private readonly ILogger<ProductController> _logger; |
| | | 16 | | private readonly ProductService _service; |
| | | 17 | | |
| | | 18 | | |
| | | 19 | | [HttpPost] |
| | 0 | 20 | | public async Task<IActionResult> CreateProduct([FromBody] product product) { |
| | 0 | 21 | | if (product == null) { |
| | 0 | 22 | | return BadRequest("Product is null."); |
| | | 23 | | } |
| | 0 | 24 | | await Task.Delay(1); |
| | 0 | 25 | | return CreatedAtAction(nameof(CreateProduct), new { id = product.product_id }, product); |
| | 0 | 26 | | } |
| | | 27 | | |
| | | 28 | | [HttpPut("{id}")] |
| | 0 | 29 | | public async Task<IActionResult> UpdateProduct(int id, [FromBody] product product) { |
| | 0 | 30 | | await Task.Delay(1); |
| | 0 | 31 | | return NoContent(); |
| | 0 | 32 | | } |
| | | 33 | | |
| | | 34 | | [HttpPatch("{id}")] |
| | 0 | 35 | | public async Task<IActionResult> PatchProduct(int id, [FromBody] JsonElement updates) { |
| | 0 | 36 | | await Task.Delay(1); |
| | 0 | 37 | | return Ok(); |
| | 0 | 38 | | } |
| | | 39 | | |
| | | 40 | | // DELETE: api/Products/5 |
| | | 41 | | [HttpDelete("{id}")] |
| | 0 | 42 | | public async Task<IActionResult> DeleteProduct(int id) { |
| | 0 | 43 | | await Task.Delay(1); |
| | 0 | 44 | | return NoContent(); |
| | 0 | 45 | | } |
| | | 46 | | } |
| | | 47 | | |