diff --git a/APIFicheros/APIFicheros.csproj b/APIFicheros/APIFicheros.csproj new file mode 100644 index 0000000..5419ef0 --- /dev/null +++ b/APIFicheros/APIFicheros.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/APIFicheros/APIFicheros.http b/APIFicheros/APIFicheros.http new file mode 100644 index 0000000..ee91da2 --- /dev/null +++ b/APIFicheros/APIFicheros.http @@ -0,0 +1,6 @@ +@APIFicheros_HostAddress = http://localhost:5219 + +GET {{APIFicheros_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/APIFicheros/Controllers/WeatherForecastController.cs b/APIFicheros/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..9216ce9 --- /dev/null +++ b/APIFicheros/Controllers/WeatherForecastController.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; + +namespace APIFicheros.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 = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } +} diff --git a/APIFicheros/Program.cs b/APIFicheros/Program.cs new file mode 100644 index 0000000..48863a6 --- /dev/null +++ b/APIFicheros/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/APIFicheros/Properties/launchSettings.json b/APIFicheros/Properties/launchSettings.json new file mode 100644 index 0000000..8f79618 --- /dev/null +++ b/APIFicheros/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:3277", + "sslPort": 44319 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5219", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7224;http://localhost:5219", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/APIFicheros/WeatherForecast.cs b/APIFicheros/WeatherForecast.cs new file mode 100644 index 0000000..4d1de37 --- /dev/null +++ b/APIFicheros/WeatherForecast.cs @@ -0,0 +1,12 @@ +namespace APIFicheros; + +public class WeatherForecast +{ + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } +} diff --git a/APIFicheros/appsettings.Development.json b/APIFicheros/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/APIFicheros/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/APIFicheros/appsettings.json b/APIFicheros/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/APIFicheros/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Asegasa.sln b/Asegasa.sln index 6d42cc7..a90479f 100644 --- a/Asegasa.sln +++ b/Asegasa.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bdfactu", "..\Tecnosis\tsFa EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tsVeriFactu", "..\Tecnosis\tsVeriFactu\tsVeriFactu.csproj", "{947E1B2F-7877-66E7-8DF0-282429B770F0}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "APIFicheros", "APIFicheros\APIFicheros.csproj", "{729F814F-BBAF-A079-B0A1-D5890DA11543}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,6 +35,10 @@ Global {947E1B2F-7877-66E7-8DF0-282429B770F0}.Debug|Any CPU.Build.0 = Debug|Any CPU {947E1B2F-7877-66E7-8DF0-282429B770F0}.Release|Any CPU.ActiveCfg = Release|Any CPU {947E1B2F-7877-66E7-8DF0-282429B770F0}.Release|Any CPU.Build.0 = Release|Any CPU + {729F814F-BBAF-A079-B0A1-D5890DA11543}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {729F814F-BBAF-A079-B0A1-D5890DA11543}.Debug|Any CPU.Build.0 = Debug|Any CPU + {729F814F-BBAF-A079-B0A1-D5890DA11543}.Release|Any CPU.ActiveCfg = Release|Any CPU + {729F814F-BBAF-A079-B0A1-D5890DA11543}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE