Skip to content

Commit d7ad602

Browse files
committed
chore(api): initialized backend donet porject
1 parent 04675c9 commit d7ad602

21 files changed

Lines changed: 1332 additions & 0 deletions

‎BackendSaaS.Api.csproj‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.10" />
11+
</ItemGroup>
12+
13+
</Project>

‎BackendSaaS.Api.http‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@BackendSaaS.Api_HostAddress = http://localhost:5048
2+
3+
GET {{BackendSaaS.Api_HostAddress}}/weatherforecast/
4+
Accept: application/json
5+
6+
###

‎BackendSaaS.Api.sln‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.5.2.0
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackendSaaS.Api", "BackendSaaS.Api.csproj", "{A5B3B1FF-AD59-4835-4B0D-972A0633D044}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|Any CPU = Debug|Any CPU
10+
Release|Any CPU = Release|Any CPU
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{A5B3B1FF-AD59-4835-4B0D-972A0633D044}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14+
{A5B3B1FF-AD59-4835-4B0D-972A0633D044}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{A5B3B1FF-AD59-4835-4B0D-972A0633D044}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{A5B3B1FF-AD59-4835-4B0D-972A0633D044}.Release|Any CPU.Build.0 = Release|Any CPU
17+
EndGlobalSection
18+
GlobalSection(SolutionProperties) = preSolution
19+
HideSolutionNode = FALSE
20+
EndGlobalSection
21+
GlobalSection(ExtensibilityGlobals) = postSolution
22+
SolutionGuid = {98011E96-B92B-4BC1-A774-26C213FAA857}
23+
EndGlobalSection
24+
EndGlobal
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace BackendSaaS.Api.Controllers;
4+
5+
[ApiController]
6+
[Route("[controller]")]
7+
public class WeatherForecastController : ControllerBase
8+
{
9+
private static readonly string[] Summaries =
10+
[
11+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12+
];
13+
14+
[HttpGet(Name = "GetWeatherForecast")]
15+
public IEnumerable<WeatherForecast> Get()
16+
{
17+
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
18+
{
19+
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
20+
TemperatureC = Random.Shared.Next(-20, 55),
21+
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
22+
})
23+
.ToArray();
24+
}
25+
}

‎Program.cs‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var builder = WebApplication.CreateBuilder(args);
2+
3+
// Add services to the container.
4+
5+
builder.Services.AddControllers();
6+
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
7+
builder.Services.AddOpenApi();
8+
9+
var app = builder.Build();
10+
11+
// Configure the HTTP request pipeline.
12+
if (app.Environment.IsDevelopment())
13+
{
14+
app.MapOpenApi();
15+
}
16+
17+
app.UseHttpsRedirection();
18+
19+
app.UseAuthorization();
20+
21+
app.MapControllers();
22+
23+
app.Run();

‎Properties/launchSettings.json‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": false,
8+
"applicationUrl": "http://localhost:5048",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development"
11+
}
12+
},
13+
"https": {
14+
"commandName": "Project",
15+
"dotnetRunMessages": true,
16+
"launchBrowser": false,
17+
"applicationUrl": "https://localhost:7139;http://localhost:5048",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
}
22+
}
23+
}

‎WeatherForecast.cs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace BackendSaaS.Api;
2+
3+
public class WeatherForecast
4+
{
5+
public DateOnly Date { get; set; }
6+
7+
public int TemperatureC { get; set; }
8+
9+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
10+
11+
public string? Summary { get; set; }
12+
}

‎appsettings.Development.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}

‎appsettings.json‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}

0 commit comments

Comments
 (0)