feat: default API with ticket

This commit is contained in:
2026-03-13 15:02:59 +01:00
commit 59344ce6a9
8 changed files with 155 additions and 0 deletions

25
.gitignore vendored Normal file
View File

@@ -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

View 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;} = "";
}
}

22
Program.cs Normal file
View File

@@ -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();

View File

@@ -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"
}
}
}
}

13
TicketAppIncrArchi.csproj Normal file
View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.4" />
</ItemGroup>
</Project>

6
TicketAppIncrArchi.http Normal file
View File

@@ -0,0 +1,6 @@
@TicketAppIncrArchi_HostAddress = http://localhost:5101
GET {{TicketAppIncrArchi_HostAddress}}/weatherforecast/
Accept: application/json
###

24
TicketAppIncrArchi.sln Normal file
View File

@@ -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

9
appsettings.json Normal file
View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}