Umstrukturierung Data zu Models

David
Naumann 2 years ago
parent 9d19fa9b14
commit f02e1e35a8
  1. 36
      .vscode/launch.json
  2. 42
      .vscode/tasks.json
  3. 2
      Controllers/InventarController.cs
  4. 1
      Controllers/KatalogController.cs
  5. 4
      Controllers/LendController.cs
  6. 26
      Data/KatalogRepo.cs
  7. 26
      Data/MockLendRepo.cs
  8. 2
      Models/IBookRepo.cs
  9. 2
      Models/IItemRepo.cs
  10. 2
      Models/ILendRepo.cs
  11. 2
      Models/IRepository.cs
  12. 2
      Models/Repository.cs
  13. 3
      Models/Tables.cs
  14. 2
      Startup.cs

@ -0,0 +1,36 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/BuecherwurmAPI.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}

42
.vscode/tasks.json vendored

@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/BuecherwurmAPI.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/BuecherwurmAPI.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/BuecherwurmAPI.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}

@ -3,7 +3,7 @@ using BuecherwurmAPI.Models;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
//using Microsoft.EntityFrameworkCore;
using BuecherwurmAPI.Data;
namespace BuecherwurmAPI.Controllers
{

@ -3,7 +3,6 @@ using BuecherwurmAPI.Models;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
//using Microsoft.EntityFrameworkCore;
using BuecherwurmAPI.Data;
namespace BuecherwurmAPI.Controllers
{

@ -3,12 +3,12 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using BuecherwurmAPI.Data;
using BuecherwurmAPI.Models;
using BuecherwurmAPI.DTOs;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.JsonPatch;
using Microsoft.Extensions.Logging;
using BuecherwurmAPI.Models;
namespace BuecherwurmAPI.Controllers
{

@ -1,26 +0,0 @@
using System.Collections.Generic;
using BuecherwurmAPI.Models;
using Microsoft.AspNetCore.Mvc;
namespace BuecherwurmAPI.Data
{
public class KatalogRepo
{
private readonly object _context;
public KatalogRepo (object context)
{
_context = context;
}
/*public IEnumerable<Book> GetAllBooks()
{
return _context.books.ToList();
}*/
/*public Book GetBookById(int id)
{
return _context.FirstOrDefault(p => p.Id == id);
}*/
}
}

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

@ -1,7 +1,7 @@
using System.Collections.Generic;
using BuecherwurmAPI.Models;
namespace BuecherwurmAPI.Data
namespace BuecherwurmAPI.Models
{
public interface IBookRepo
{

@ -1,7 +1,7 @@
using System.Collections.Generic;
using BuecherwurmAPI.Models;
namespace BuecherwurmAPI.Data
namespace BuecherwurmAPI.Models
{
public interface IItemRepo
{

@ -1,7 +1,7 @@
using System.Collections.Generic;
using BuecherwurmAPI.Models;
namespace BuecherwurmAPI.Data
namespace BuecherwurmAPI.Models
{
public interface ILendRepo
{

@ -2,7 +2,7 @@ using System.Collections.Generic;
using BuecherwurmAPI.Models;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
namespace BuecherwurmAPI.Data
namespace BuecherwurmAPI.Models
{
public interface IRepository
{

@ -4,7 +4,7 @@ using BuecherwurmAPI.Models;
using Microsoft.Data.Sqlite;
using Microsoft.VisualBasic.CompilerServices;
namespace BuecherwurmAPI.Data
namespace BuecherwurmAPI.Models
{
internal class Repository : IRepository
{

@ -1,10 +1,11 @@
namespace BuecherwurmAPI.Data
namespace BuecherwurmAPI.Models
{
public static class Tables
{
public struct Table
{
public const string Lends = "Lends";
public const string Katalog = "Katalog";
}
}
}

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using BuecherwurmAPI.Data;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
@ -12,6 +11,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using BuecherwurmAPI.Models;
namespace BuecherwurmAPI
{

Loading…
Cancel
Save