feat: default API with ticket
This commit is contained in:
33
Controllers/TicketsController.cs
Normal file
33
Controllers/TicketsController.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace TicketAppIncrArchi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/tickets")]
|
||||
public class TicketsController : ControllerBase
|
||||
{
|
||||
|
||||
private static List<Ticket> Tickets = new();
|
||||
|
||||
[HttpGet]
|
||||
public IEnumerable<Ticket> Get() => Tickets;
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Create(Ticket ticket)
|
||||
{
|
||||
ticket.Id = Guid.NewGuid();
|
||||
|
||||
Tickets.Add(ticket);
|
||||
return CreatedAtAction(nameof(Get), new {id = ticket.Id}, ticket);
|
||||
}
|
||||
|
||||
public class Ticket
|
||||
{
|
||||
public Guid Id {get;set;}
|
||||
public string Title {get;set;} = "";
|
||||
public string Description {get;set;} = "";
|
||||
//public string Status {get;set;} = "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user