diff --git a/src/Coupon.API/Controllers/WeatherForecastController.cs b/src/Coupon.API/Controllers/WeatherForecastController.cs new file mode 100644 index 000000000..d17e15b7b --- /dev/null +++ b/src/Coupon.API/Controllers/WeatherForecastController.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Coupon.API.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/src/Coupon.API/Coupon.API.csproj b/src/Coupon.API/Coupon.API.csproj new file mode 100644 index 000000000..6108b7b28 --- /dev/null +++ b/src/Coupon.API/Coupon.API.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/src/Coupon.API/Program.cs b/src/Coupon.API/Program.cs new file mode 100644 index 000000000..8264bac54 --- /dev/null +++ b/src/Coupon.API/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(); \ No newline at end of file diff --git a/src/Coupon.API/Properties/launchSettings.json b/src/Coupon.API/Properties/launchSettings.json new file mode 100644 index 000000000..cec5d8a06 --- /dev/null +++ b/src/Coupon.API/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:26091", + "sslPort": 44325 + } + }, + "profiles": { + "Coupon.API": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7014;http://localhost:5106", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/Coupon.API/WeatherForecast.cs b/src/Coupon.API/WeatherForecast.cs new file mode 100644 index 000000000..ce301413f --- /dev/null +++ b/src/Coupon.API/WeatherForecast.cs @@ -0,0 +1,12 @@ +namespace Coupon.API; + +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/src/Coupon.API/appsettings.Development.json b/src/Coupon.API/appsettings.Development.json new file mode 100644 index 000000000..0c208ae91 --- /dev/null +++ b/src/Coupon.API/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/Coupon.API/appsettings.json b/src/Coupon.API/appsettings.json new file mode 100644 index 000000000..10f68b8c8 --- /dev/null +++ b/src/Coupon.API/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/src/eShopOnContainers-ServicesAndWebApps.sln b/src/eShopOnContainers-ServicesAndWebApps.sln index 446614fc0..05021db2c 100644 --- a/src/eShopOnContainers-ServicesAndWebApps.sln +++ b/src/eShopOnContainers-ServicesAndWebApps.sln @@ -124,6 +124,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{373D8AA1 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventBus.Tests", "BuildingBlocks\EventBus\EventBus.Tests\EventBus.Tests.csproj", "{95D735BE-2899-4495-BE3F-2600E93B4E3C}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Coupon", "Coupon", "{EA8E5543-46DB-4646-B29B-847756FF0B37}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Coupon.API", "Coupon.API\Coupon.API.csproj", "{A50CFB1D-A31D-4399-9115-CF79A004E106}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Ad-Hoc|Any CPU = Ad-Hoc|Any CPU @@ -1530,6 +1534,54 @@ Global {95D735BE-2899-4495-BE3F-2600E93B4E3C}.Release|x64.Build.0 = Release|Any CPU {95D735BE-2899-4495-BE3F-2600E93B4E3C}.Release|x86.ActiveCfg = Release|Any CPU {95D735BE-2899-4495-BE3F-2600E93B4E3C}.Release|x86.Build.0 = Release|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.AppStore|ARM.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.AppStore|iPhone.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.AppStore|x64.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.AppStore|x64.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.AppStore|x86.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.AppStore|x86.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Debug|ARM.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Debug|ARM.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Debug|iPhone.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Debug|x64.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Debug|x64.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Debug|x86.ActiveCfg = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Debug|x86.Build.0 = Debug|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Release|Any CPU.Build.0 = Release|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Release|ARM.ActiveCfg = Release|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Release|ARM.Build.0 = Release|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Release|iPhone.ActiveCfg = Release|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Release|iPhone.Build.0 = Release|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Release|x64.ActiveCfg = Release|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Release|x64.Build.0 = Release|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Release|x86.ActiveCfg = Release|Any CPU + {A50CFB1D-A31D-4399-9115-CF79A004E106}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1588,6 +1640,8 @@ Global {B62E859F-825E-4C8B-93EC-5966EACFD026} = {798BFC44-2CCD-45FA-B37A-5173B03C2B30} {373D8AA1-36BE-49EC-89F0-6CB736666285} = {807BB76E-B2BB-47A2-A57B-3D1B20FF5E7F} {95D735BE-2899-4495-BE3F-2600E93B4E3C} = {373D8AA1-36BE-49EC-89F0-6CB736666285} + {EA8E5543-46DB-4646-B29B-847756FF0B37} = {91CF7717-08AB-4E65-B10E-0B426F01E2E8} + {A50CFB1D-A31D-4399-9115-CF79A004E106} = {EA8E5543-46DB-4646-B29B-847756FF0B37} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9}