diff --git a/Pizzeria/PizzeriaRestApi/Controllers/WeatherForecastController.cs b/Pizzeria/PizzeriaRestApi/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..0113888 --- /dev/null +++ b/Pizzeria/PizzeriaRestApi/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace PizzeriaRestApi.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateTime.Now.AddDays(index), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} \ No newline at end of file diff --git a/Pizzeria/PizzeriaRestApi/PizzeriaRestApi.csproj b/Pizzeria/PizzeriaRestApi/PizzeriaRestApi.csproj new file mode 100644 index 0000000..60bf9ea --- /dev/null +++ b/Pizzeria/PizzeriaRestApi/PizzeriaRestApi.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/Pizzeria/PizzeriaRestApi/Program.cs b/Pizzeria/PizzeriaRestApi/Program.cs new file mode 100644 index 0000000..48863a6 --- /dev/null +++ b/Pizzeria/PizzeriaRestApi/Program.cs @@ -0,0 +1,25 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/Pizzeria/PizzeriaRestApi/Properties/launchSettings.json b/Pizzeria/PizzeriaRestApi/Properties/launchSettings.json new file mode 100644 index 0000000..2a1602c --- /dev/null +++ b/Pizzeria/PizzeriaRestApi/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:25830", + "sslPort": 44338 + } + }, + "profiles": { + "PizzeriaRestApi": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7115;http://localhost:5115", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Pizzeria/PizzeriaRestApi/WeatherForecast.cs b/Pizzeria/PizzeriaRestApi/WeatherForecast.cs new file mode 100644 index 0000000..9222616 --- /dev/null +++ b/Pizzeria/PizzeriaRestApi/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace PizzeriaRestApi +{ + public class WeatherForecast + { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} \ No newline at end of file diff --git a/Pizzeria/PizzeriaRestApi/appsettings.Development.json b/Pizzeria/PizzeriaRestApi/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Pizzeria/PizzeriaRestApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Pizzeria/PizzeriaRestApi/appsettings.json b/Pizzeria/PizzeriaRestApi/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Pizzeria/PizzeriaRestApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}