diff --git a/Directory.Packages.props b/Directory.Packages.props index d0debbec..625136bc 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -28,5 +28,7 @@ + + \ No newline at end of file diff --git a/Marechai.Server/Controllers/WeatherForecastController.cs b/Marechai.Server/Controllers/WeatherForecastController.cs new file mode 100644 index 00000000..a307510a --- /dev/null +++ b/Marechai.Server/Controllers/WeatherForecastController.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Marechai.Server.Controllers; + +[ApiController] +[Route("[controller]")] +public class WeatherForecastController : ControllerBase +{ + private static readonly string[] Summaries = + [ + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + ]; + + [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(); + } +} \ No newline at end of file diff --git a/Marechai.Server/Marechai.Server.csproj b/Marechai.Server/Marechai.Server.csproj new file mode 100644 index 00000000..9d0d97c8 --- /dev/null +++ b/Marechai.Server/Marechai.Server.csproj @@ -0,0 +1,11 @@ + + + + net10.0 + + + + + + + diff --git a/Marechai.Server/Program.cs b/Marechai.Server/Program.cs new file mode 100644 index 00000000..3ebdd501 --- /dev/null +++ b/Marechai.Server/Program.cs @@ -0,0 +1,37 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Marechai.Server; + +public class Program +{ + public static void Main(string[] args) + { + 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(); + } + + app.UseHttpsRedirection(); + + app.UseAuthorization(); + + + app.MapControllers(); + + app.Run(); + } +} \ No newline at end of file diff --git a/Marechai.Server/WeatherForecast.cs b/Marechai.Server/WeatherForecast.cs new file mode 100644 index 00000000..811acb82 --- /dev/null +++ b/Marechai.Server/WeatherForecast.cs @@ -0,0 +1,12 @@ +namespace Marechai.Server; + +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; } +} \ No newline at end of file diff --git a/Marechai.Server/appsettings.json b/Marechai.Server/appsettings.json new file mode 100644 index 00000000..10f68b8c --- /dev/null +++ b/Marechai.Server/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Marechai.sln b/Marechai.sln index 78bb6d6c..0d66eb54 100644 --- a/Marechai.sln +++ b/Marechai.sln @@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Directory.Packages.props = Directory.Packages.props EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Marechai.Server", "Marechai.Server\Marechai.Server.csproj", "{1371F202-4316-4FA4-93A2-8FF0FC136A33}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {F914D5B9-0C7F-4A40-B187-269B83497AF8}.Debug|Any CPU.Build.0 = Debug|Any CPU {F914D5B9-0C7F-4A40-B187-269B83497AF8}.Release|Any CPU.ActiveCfg = Release|Any CPU {F914D5B9-0C7F-4A40-B187-269B83497AF8}.Release|Any CPU.Build.0 = Release|Any CPU + {1371F202-4316-4FA4-93A2-8FF0FC136A33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1371F202-4316-4FA4-93A2-8FF0FC136A33}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1371F202-4316-4FA4-93A2-8FF0FC136A33}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1371F202-4316-4FA4-93A2-8FF0FC136A33}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE