From 59344ce6a9307f8c955a6655a511ea75f0d8621c Mon Sep 17 00:00:00 2001 From: Romain Mallard Date: Fri, 13 Mar 2026 15:02:59 +0100 Subject: [PATCH] feat: default API with ticket --- .gitignore | 25 ++++++++++++++++++++++++ Controllers/TicketsController.cs | 33 ++++++++++++++++++++++++++++++++ Program.cs | 22 +++++++++++++++++++++ Properties/launchSettings.json | 23 ++++++++++++++++++++++ TicketAppIncrArchi.csproj | 13 +++++++++++++ TicketAppIncrArchi.http | 6 ++++++ TicketAppIncrArchi.sln | 24 +++++++++++++++++++++++ appsettings.json | 9 +++++++++ 8 files changed, 155 insertions(+) create mode 100644 .gitignore create mode 100644 Controllers/TicketsController.cs create mode 100644 Program.cs create mode 100644 Properties/launchSettings.json create mode 100644 TicketAppIncrArchi.csproj create mode 100644 TicketAppIncrArchi.http create mode 100644 TicketAppIncrArchi.sln create mode 100644 appsettings.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c0df4b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# Build results +bin/ +obj/ + +# User-specific files +*.user +*.rsuser +*.suo + +# Visual Studio +.vs/ + +# Rider +.idea/ + +# Logs +*.log + +# OS files +.DS_Store +Thumbs.db + +# Environment / secrets +.env +appsettings.Development.json \ No newline at end of file diff --git a/Controllers/TicketsController.cs b/Controllers/TicketsController.cs new file mode 100644 index 0000000..1015523 --- /dev/null +++ b/Controllers/TicketsController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace TicketAppIncrArchi.Controllers; + +[ApiController] +[Route("api/tickets")] +public class TicketsController : ControllerBase +{ + + private static List Tickets = new(); + + [HttpGet] + public IEnumerable 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;} = ""; + } + + +} diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..295be6f --- /dev/null +++ b/Program.cs @@ -0,0 +1,22 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +builder.Services.AddControllers(); + +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddOpenApi(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); +} + +//---Disabled for dev purpose +//app.UseHttpsRedirection(); +//app.UseAuthorization(); + +app.MapControllers(); +app.Run(); diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..6d61ea3 --- /dev/null +++ b/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5101", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7091;http://localhost:5101", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/TicketAppIncrArchi.csproj b/TicketAppIncrArchi.csproj new file mode 100644 index 0000000..d3e210a --- /dev/null +++ b/TicketAppIncrArchi.csproj @@ -0,0 +1,13 @@ + + + + net10.0 + enable + enable + + + + + + + diff --git a/TicketAppIncrArchi.http b/TicketAppIncrArchi.http new file mode 100644 index 0000000..5dc7c84 --- /dev/null +++ b/TicketAppIncrArchi.http @@ -0,0 +1,6 @@ +@TicketAppIncrArchi_HostAddress = http://localhost:5101 + +GET {{TicketAppIncrArchi_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/TicketAppIncrArchi.sln b/TicketAppIncrArchi.sln new file mode 100644 index 0000000..6537fdd --- /dev/null +++ b/TicketAppIncrArchi.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.2.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TicketAppIncrArchi", "TicketAppIncrArchi.csproj", "{D6E0EF9A-77FD-6BB5-854D-B97DFF366D1F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D6E0EF9A-77FD-6BB5-854D-B97DFF366D1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D6E0EF9A-77FD-6BB5-854D-B97DFF366D1F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6E0EF9A-77FD-6BB5-854D-B97DFF366D1F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D6E0EF9A-77FD-6BB5-854D-B97DFF366D1F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B8F5108D-4717-4702-9292-B9C62A76086A} + EndGlobalSection +EndGlobal diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}