feat: default API with ticket
This commit is contained in:
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal 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
|
||||||
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;} = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
22
Program.cs
Normal file
22
Program.cs
Normal 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();
|
||||||
23
Properties/launchSettings.json
Normal file
23
Properties/launchSettings.json
Normal 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
13
TicketAppIncrArchi.csproj
Normal 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
6
TicketAppIncrArchi.http
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
@TicketAppIncrArchi_HostAddress = http://localhost:5101
|
||||||
|
|
||||||
|
GET {{TicketAppIncrArchi_HostAddress}}/weatherforecast/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
||||||
24
TicketAppIncrArchi.sln
Normal file
24
TicketAppIncrArchi.sln
Normal 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
9
appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user