diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 2e3d0ef..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -obj/ -bin/ \ No newline at end of file diff --git a/BuecherwurmAPI.csproj b/BuecherwurmAPI.csproj index ac340e9..400722f 100644 --- a/BuecherwurmAPI.csproj +++ b/BuecherwurmAPI.csproj @@ -1,13 +1,8 @@ - netcoreapp2.2 - InProcess + netcoreapp3.1 - - - - diff --git a/Controllers/ValuesController.cs b/Controllers/ValuesController.cs deleted file mode 100644 index 0f0e308..0000000 --- a/Controllers/ValuesController.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; - -namespace BuecherwurmAPI.Controllers -{ - [Route("api/[controller]")] - [ApiController] - public class ValuesController : ControllerBase - { - // GET api/values - [HttpGet] - public ActionResult> Get() - { - return new string[] { "value1", "value2" }; - } - - // GET api/values/5 - [HttpGet("{id}")] - public ActionResult Get(int id) - { - return "value"; - } - - // POST api/values - [HttpPost] - public void Post([FromBody] string value) - { - } - - // PUT api/values/5 - [HttpPut("{id}")] - public void Put(int id, [FromBody] string value) - { - } - - // DELETE api/values/5 - [HttpDelete("{id}")] - public void Delete(int id) - { - } - } -} diff --git a/Controllers/WeatherForecastController.cs b/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..74bac7e --- /dev/null +++ b/Controllers/WeatherForecastController.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace BuecherwurmAPI.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] + public IEnumerable Get() + { + var rng = new Random(); + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateTime.Now.AddDays(index), + TemperatureC = rng.Next(-20, 55), + Summary = Summaries[rng.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/Program.cs b/Program.cs index 610a729..e60685a 100644 --- a/Program.cs +++ b/Program.cs @@ -1,11 +1,10 @@ -using System; +using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace BuecherwurmAPI @@ -14,11 +13,14 @@ namespace BuecherwurmAPI { public static void Main(string[] args) { - CreateWebHostBuilder(args).Build().Run(); + CreateHostBuilder(args).Build().Run(); } - public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); } } diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index 84ab63d..106829e 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -1,18 +1,18 @@ { "$schema": "http://json.schemastore.org/launchsettings.json", "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, + "windowsAuthentication": false, + "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:61571", - "sslPort": 44383 + "applicationUrl": "http://localhost:5975", + "sslPort": 44376 } }, "profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, - "launchUrl": "api/values", + "launchUrl": "weatherforecast", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -20,11 +20,11 @@ "BuecherwurmAPI": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "api/values", + "launchUrl": "weatherforecast", "applicationUrl": "https://localhost:5001;http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } -} \ No newline at end of file +} diff --git a/README.md b/README.md deleted file mode 100644 index db7edd0..0000000 --- a/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# BuecherwurmAPI - -Dies ist die Implementation der Aufgabe "Bücherwurm API". - -Ziel der Aufgabe ist es eine JSON RESTful-API zur Verwaltung von Medienausleihen zu programmieren. \ No newline at end of file diff --git a/Startup.cs b/Startup.cs index 75fc48f..1bdfe77 100644 --- a/Startup.cs +++ b/Startup.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -8,8 +8,8 @@ using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; namespace BuecherwurmAPI { @@ -25,24 +25,27 @@ namespace BuecherwurmAPI // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + services.AddControllers(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); - } app.UseHttpsRedirection(); - app.UseMvc(); + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); } } } diff --git a/WeatherForecast.cs b/WeatherForecast.cs new file mode 100644 index 0000000..7046a72 --- /dev/null +++ b/WeatherForecast.cs @@ -0,0 +1,15 @@ +using System; + +namespace BuecherwurmAPI +{ + 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; } + } +} diff --git a/appsettings.Development.json b/appsettings.Development.json index a2880cb..dba68eb 100644 --- a/appsettings.Development.json +++ b/appsettings.Development.json @@ -1,9 +1,9 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Debug", - "System": "Information", - "Microsoft": "Information" - } - } -} +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/appsettings.json b/appsettings.json index 7376aad..81ff877 100644 --- a/appsettings.json +++ b/appsettings.json @@ -1,7 +1,9 @@ { "Logging": { "LogLevel": { - "Default": "Warning" + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" } }, "AllowedHosts": "*" diff --git a/obj/BuecherwurmAPI.csproj.nuget.dgspec.json b/obj/BuecherwurmAPI.csproj.nuget.dgspec.json new file mode 100644 index 0000000..519046e --- /dev/null +++ b/obj/BuecherwurmAPI.csproj.nuget.dgspec.json @@ -0,0 +1,67 @@ +{ + "format": 1, + "restore": { + "/home/js/git/BuecherwurmAPI/BuecherwurmAPI/BuecherwurmAPI.csproj": {} + }, + "projects": { + "/home/js/git/BuecherwurmAPI/BuecherwurmAPI/BuecherwurmAPI.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "/home/js/git/BuecherwurmAPI/BuecherwurmAPI/BuecherwurmAPI.csproj", + "projectName": "BuecherwurmAPI", + "projectPath": "/home/js/git/BuecherwurmAPI/BuecherwurmAPI/BuecherwurmAPI.csproj", + "packagesPath": "/home/js/.nuget/packages/", + "outputPath": "/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/", + "projectStyle": "PackageReference", + "configFilePaths": [ + "/home/js/.nuget/NuGet/NuGet.Config" + ], + "originalTargetFrameworks": [ + "netcoreapp3.1" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "netcoreapp3.1": { + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "netcoreapp3.1": { + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48" + ], + "assetTargetFallback": true, + "warn": true, + "downloadDependencies": [ + { + "name": "Microsoft.AspNetCore.App.Ref", + "version": "[3.1.2, 3.1.2]" + } + ], + "frameworkReferences": { + "Microsoft.AspNetCore.App": { + "privateAssets": "none" + }, + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/3.1.300/RuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/obj/BuecherwurmAPI.csproj.nuget.g.props b/obj/BuecherwurmAPI.csproj.nuget.g.props new file mode 100644 index 0000000..db837e3 --- /dev/null +++ b/obj/BuecherwurmAPI.csproj.nuget.g.props @@ -0,0 +1,15 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + /home/js/.nuget/packages/ + /home/js/.nuget/packages/ + PackageReference + 5.6.0 + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + + \ No newline at end of file diff --git a/obj/BuecherwurmAPI.csproj.nuget.g.targets b/obj/BuecherwurmAPI.csproj.nuget.g.targets new file mode 100644 index 0000000..53cfaa1 --- /dev/null +++ b/obj/BuecherwurmAPI.csproj.nuget.g.targets @@ -0,0 +1,6 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + + \ No newline at end of file diff --git a/obj/project.assets.json b/obj/project.assets.json new file mode 100644 index 0000000..dcf1392 --- /dev/null +++ b/obj/project.assets.json @@ -0,0 +1,72 @@ +{ + "version": 3, + "targets": { + ".NETCoreApp,Version=v3.1": {} + }, + "libraries": {}, + "projectFileDependencyGroups": { + ".NETCoreApp,Version=v3.1": [] + }, + "packageFolders": { + "/home/js/.nuget/packages/": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "/home/js/git/BuecherwurmAPI/BuecherwurmAPI/BuecherwurmAPI.csproj", + "projectName": "BuecherwurmAPI", + "projectPath": "/home/js/git/BuecherwurmAPI/BuecherwurmAPI/BuecherwurmAPI.csproj", + "packagesPath": "/home/js/.nuget/packages/", + "outputPath": "/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/", + "projectStyle": "PackageReference", + "configFilePaths": [ + "/home/js/.nuget/NuGet/NuGet.Config" + ], + "originalTargetFrameworks": [ + "netcoreapp3.1" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "netcoreapp3.1": { + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "netcoreapp3.1": { + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48" + ], + "assetTargetFallback": true, + "warn": true, + "downloadDependencies": [ + { + "name": "Microsoft.AspNetCore.App.Ref", + "version": "[3.1.2, 3.1.2]" + } + ], + "frameworkReferences": { + "Microsoft.AspNetCore.App": { + "privateAssets": "none" + }, + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/3.1.300/RuntimeIdentifierGraph.json" + } + } + } +} \ No newline at end of file diff --git a/obj/project.nuget.cache b/obj/project.nuget.cache new file mode 100644 index 0000000..b0958fd --- /dev/null +++ b/obj/project.nuget.cache @@ -0,0 +1,10 @@ +{ + "version": 2, + "dgSpecHash": "DQHTkigAmzaLDZvres1QqICGpp078kH+e2RcIw20S2aZ61FIcBBy9GnDIw6JTzZ4/RxJvQ1+WRFn2orctypbfA==", + "success": true, + "projectFilePath": "/home/js/git/BuecherwurmAPI/BuecherwurmAPI/BuecherwurmAPI.csproj", + "expectedPackageFiles": [ + "/home/js/.nuget/packages/microsoft.aspnetcore.app.ref/3.1.2/microsoft.aspnetcore.app.ref.3.1.2.nupkg.sha512" + ], + "logs": [] +} \ No newline at end of file