Erster Zwischenstand für die Ausleihe-Schnittstelle (mit Mock-Data)

api/leihvorgang  -- gibt Liste aller Leihvorgänge zurück
api/leihvorgang/{id} -- gibt bestimmten Leihvorgang zurück
This commit is contained in:
Jonas Schönbach 2020-05-27 10:08:52 +02:00
parent a3118e8891
commit fbe1e58a47
39 changed files with 3633 additions and 56 deletions

View file

@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/modules.xml
/contentModel.xml
/projectSettingsUpdater.xml
/.idea.BuecherwurmAPI.iml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="RIDER_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ContentModelUserStore">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="RIDER_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$/../.." />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BuecherwurmAPI.Data;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using BuecherwurmAPI.Models;
namespace BuecherwurmAPI.Controllers
{
[Route("api/leihvorgang")]
[ApiController]
public class LendController : ControllerBase
{
private readonly MockLendRepo _mockLendRepo = new MockLendRepo();
//GET api/leihvorgang/
[HttpGet]
public ActionResult<IEnumerable<Lend>> GetAllLends()
{
var lends = _mockLendRepo.GetAllLends();
return Ok(lends);
}
//GET api/leihvorgang/{id}
[HttpGet("{id}")]
public ActionResult<Lend> GetLend(int id)
{
var lend = _mockLendRepo.GetLendById(id);
return Ok(lend);
}
}
}

View file

@ -1,39 +0,0 @@
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<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet]
public IEnumerable<WeatherForecast> 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();
}
}
}

11
Data/ILendRepo.cs Normal file
View file

@ -0,0 +1,11 @@
using System.Collections.Generic;
using BuecherwurmAPI.Models;
namespace BuecherwurmAPI.Data
{
public interface ILendRepo
{
IEnumerable<Lend> GetAllLends();
Lend GetLendById(int id);
}
}

26
Data/MockLendRepo.cs Normal file
View file

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using BuecherwurmAPI.Models;
namespace BuecherwurmAPI.Data
{
public class MockLendRepo : ILendRepo
{
public IEnumerable<Lend> GetAllLends()
{
var lends = new List<Lend>
{
new Lend{Id = 1, Customer = "Nek0", ItemId = 1337, Returned = false, ReturnDate = DateTime.Now},
new Lend{Id = 2, Customer = "Shrubbery", ItemId = 1975, Returned = false, ReturnDate = DateTime.Now},
new Lend{Id = 3, Customer = "Felix", ItemId = 42, Returned = true, ReturnDate = DateTime.Now}
};
return lends;
}
public Lend GetLendById(int id)
{
return new Lend{Id = 1, Customer = "Nek0", ItemId = 1337, Returned = false, ReturnDate = DateTime.Now};
}
}
}

13
Models/Lend.cs Normal file
View file

@ -0,0 +1,13 @@
using System;
namespace BuecherwurmAPI.Models
{
public class Lend
{
public int Id { get; set; }
public int ItemId { get; set;}
public DateTime ReturnDate { get; set; }
public string Customer { get; set; }
public bool Returned { get; set; }
}
}

View file

@ -12,7 +12,7 @@
"IIS Express": { "IIS Express": {
"commandName": "IISExpress", "commandName": "IISExpress",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "weatherforecast", "launchUrl": "api",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
@ -20,7 +20,7 @@
"BuecherwurmAPI": { "BuecherwurmAPI": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "weatherforecast", "launchUrl": "api",
"applicationUrl": "https://localhost:5001;http://localhost:5000", "applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"

View file

@ -1,15 +0,0 @@
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; }
}
}

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,8 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"/home/js/.dotnet/store/|arch|/|tfm|",
"/home/js/.nuget/packages"
]
}
}

View file

@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.AspNetCore.App",
"version": "3.1.0"
},
"configProperties": {
"System.GC.Server": true
}
}
}

View file

@ -0,0 +1,30 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5975",
"sslPort": 44376
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"BuecherwurmAPI": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View file

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View file

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}

View file

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]

Binary file not shown.

View file

@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("BuecherwurmAPI")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("BuecherwurmAPI")]
[assembly: System.Reflection.AssemblyTitleAttribute("BuecherwurmAPI")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Von der MSBuild WriteCodeFragment-Klasse generiert.

View file

@ -0,0 +1 @@
0848efc0ec02497d4272fec239ac4c6242f14bec

View file

@ -0,0 +1 @@
ed9291efb2fcd04a6651c23e6d75ec73cb57b20c

Binary file not shown.

View file

@ -0,0 +1 @@
68abc5d6f4bc3db2a6f02336749f1abec3f13b94

View file

@ -0,0 +1,20 @@
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/Debug/netcoreapp3.1/BuecherwurmAPI.csprojAssemblyReference.cache
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/Debug/netcoreapp3.1/BuecherwurmAPI.AssemblyInfoInputs.cache
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/Debug/netcoreapp3.1/BuecherwurmAPI.AssemblyInfo.cs
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/Debug/netcoreapp3.1/BuecherwurmAPI.csproj.CoreCompileInputs.cache
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/Debug/netcoreapp3.1/BuecherwurmAPI.MvcApplicationPartsAssemblyInfo.cache
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/bin/Debug/netcoreapp3.1/appsettings.Development.json
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/bin/Debug/netcoreapp3.1/appsettings.json
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/bin/Debug/netcoreapp3.1/Properties/launchSettings.json
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/bin/Debug/netcoreapp3.1/BuecherwurmAPI
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/bin/Debug/netcoreapp3.1/BuecherwurmAPI.deps.json
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/bin/Debug/netcoreapp3.1/BuecherwurmAPI.runtimeconfig.json
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/bin/Debug/netcoreapp3.1/BuecherwurmAPI.runtimeconfig.dev.json
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/bin/Debug/netcoreapp3.1/BuecherwurmAPI.dll
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/bin/Debug/netcoreapp3.1/BuecherwurmAPI.pdb
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/Debug/netcoreapp3.1/BuecherwurmAPI.RazorTargetAssemblyInfo.cache
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/Debug/netcoreapp3.1/staticwebassets/BuecherwurmAPI.StaticWebAssets.Manifest.cache
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/Debug/netcoreapp3.1/staticwebassets/BuecherwurmAPI.StaticWebAssets.xml
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/Debug/netcoreapp3.1/BuecherwurmAPI.dll
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/Debug/netcoreapp3.1/BuecherwurmAPI.pdb
/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/Debug/netcoreapp3.1/BuecherwurmAPI.genruntimeconfig.cache

Binary file not shown.

View file

@ -0,0 +1 @@
86c8e15dd33445635927cfaf398408205fd11473

Binary file not shown.

View file

@ -0,0 +1 @@
<StaticWebAssets Version="1.0" />

View file

@ -0,0 +1,55 @@
{
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/js/git/BuecherwurmAPI/BuecherwurmAPI/BuecherwurmAPI.csproj",
"projectName": "BuecherwurmAPI",
"projectPath": "/home/js/git/BuecherwurmAPI/BuecherwurmAPI/BuecherwurmAPI.csproj",
"outputPath": "/home/js/git/BuecherwurmAPI/BuecherwurmAPI/obj/",
"projectStyle": "PackageReference",
"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"
}
}
}