diff --git a/Hotel/Hotel.sln b/Hotel/Hotel.sln index 22461ca..80d58e3 100644 --- a/Hotel/Hotel.sln +++ b/Hotel/Hotel.sln @@ -9,7 +9,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelDataModels", "HotelDat EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelContracts", "HotelContracts\HotelContracts.csproj", "{234B3526-A74E-43D2-9333-E74B4FF9A356}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelDataBaseImplement", "HotelDataBaseImplement\HotelDataBaseImplement.csproj", "{B32CB19B-0F73-49F1-8821-7BBAFED6A6C5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HotelDataBaseImplement", "HotelDataBaseImplement\HotelDataBaseImplement.csproj", "{B32CB19B-0F73-49F1-8821-7BBAFED6A6C5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelRestApi", "HotelRestApi\HotelRestApi.csproj", "{1D7D511E-66E9-480F-92B9-9E1A33916DCF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -33,6 +35,10 @@ Global {B32CB19B-0F73-49F1-8821-7BBAFED6A6C5}.Debug|Any CPU.Build.0 = Debug|Any CPU {B32CB19B-0F73-49F1-8821-7BBAFED6A6C5}.Release|Any CPU.ActiveCfg = Release|Any CPU {B32CB19B-0F73-49F1-8821-7BBAFED6A6C5}.Release|Any CPU.Build.0 = Release|Any CPU + {1D7D511E-66E9-480F-92B9-9E1A33916DCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1D7D511E-66E9-480F-92B9-9E1A33916DCF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1D7D511E-66E9-480F-92B9-9E1A33916DCF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1D7D511E-66E9-480F-92B9-9E1A33916DCF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Hotel/HotelRestApi/Controllers/WeatherForecastController.cs b/Hotel/HotelRestApi/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..469de39 --- /dev/null +++ b/Hotel/HotelRestApi/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace HotelRestApi.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/Hotel/HotelRestApi/HotelRestApi.csproj b/Hotel/HotelRestApi/HotelRestApi.csproj new file mode 100644 index 0000000..2cd3993 --- /dev/null +++ b/Hotel/HotelRestApi/HotelRestApi.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/Hotel/HotelRestApi/Program.cs b/Hotel/HotelRestApi/Program.cs new file mode 100644 index 0000000..d067d73 --- /dev/null +++ b/Hotel/HotelRestApi/Program.cs @@ -0,0 +1,36 @@ +using Microsoft.OpenApi.Models; + +var builder = WebApplication.CreateBuilder(args); + +builder.Logging.SetMinimumLevel(LogLevel.Trace); +builder.Logging.AddLog4Net("log4net.config"); + +/* +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddControllers();*/ +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(c => +{ + c.SwaggerDoc("v1", new OpenApiInfo + { + Title = "ConfectoneryRestApi", + Version = "v1" + }); +}); +var app = builder.Build(); +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", + "ConfectoneryRestApi v1")); +} +app.UseHttpsRedirection(); +app.UseAuthorization(); +app.MapControllers(); +app.Run(); diff --git a/Hotel/HotelRestApi/Properties/launchSettings.json b/Hotel/HotelRestApi/Properties/launchSettings.json new file mode 100644 index 0000000..b7528ce --- /dev/null +++ b/Hotel/HotelRestApi/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:18210", + "sslPort": 44326 + } + }, + "profiles": { + "HotelRestApi": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7079;http://localhost:5079", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Hotel/HotelRestApi/WeatherForecast.cs b/Hotel/HotelRestApi/WeatherForecast.cs new file mode 100644 index 0000000..78d86f6 --- /dev/null +++ b/Hotel/HotelRestApi/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace HotelRestApi +{ + 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/Hotel/HotelRestApi/appsettings.Development.json b/Hotel/HotelRestApi/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Hotel/HotelRestApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Hotel/HotelRestApi/appsettings.json b/Hotel/HotelRestApi/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Hotel/HotelRestApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Hotel/HotelRestApi/log4net.config b/Hotel/HotelRestApi/log4net.config new file mode 100644 index 0000000..43b77f9 --- /dev/null +++ b/Hotel/HotelRestApi/log4net.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file