From ab365f26ca9bbfb295aea69d915c2b37ea90d11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=B6nbach?= Date: Thu, 28 May 2020 14:05:31 +0200 Subject: [PATCH] sorry :D Ich habe ein Backup gemacht --- BuecherwurmAPI.csproj | 13 ----- Controllers/InventarController.cs | 69 ------------------------- Controllers/LendController.cs | 84 ------------------------------- DTOs/LendRead.cs | 12 ----- Data/ILendRepo.cs | 11 ---- Data/MockLendRepo.cs | 26 ---------- Models/Item.cs | 14 ------ Models/Lend.cs | 13 ----- Profiles/LendProfile.cs | 14 ------ Program.cs | 26 ---------- Properties/launchSettings.json | 30 ----------- Startup.cs | 60 ---------------------- appsettings.Development.json | 9 ---- appsettings.json | 10 ---- 14 files changed, 391 deletions(-) delete mode 100644 BuecherwurmAPI.csproj delete mode 100644 Controllers/InventarController.cs delete mode 100644 Controllers/LendController.cs delete mode 100644 DTOs/LendRead.cs delete mode 100644 Data/ILendRepo.cs delete mode 100644 Data/MockLendRepo.cs delete mode 100644 Models/Item.cs delete mode 100644 Models/Lend.cs delete mode 100644 Profiles/LendProfile.cs delete mode 100644 Program.cs delete mode 100644 Properties/launchSettings.json delete mode 100644 Startup.cs delete mode 100644 appsettings.Development.json delete mode 100644 appsettings.json diff --git a/BuecherwurmAPI.csproj b/BuecherwurmAPI.csproj deleted file mode 100644 index cfb35fd..0000000 --- a/BuecherwurmAPI.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - netcoreapp3.1 - - - - - - - - - diff --git a/Controllers/InventarController.cs b/Controllers/InventarController.cs deleted file mode 100644 index a9fc7b2..0000000 --- a/Controllers/InventarController.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Collections.Generic; -using BuecherwurmAPI.Models; -using Microsoft.AspNetCore.Mvc; -using System.Linq; -using Microsoft.EntityFrameworkCore; -using BuecherwurmAPI.Data; - -namespace BuecherwurmAPI.Controllers -{ - [Route("inventar")] - [ApiController] - public class InventarController : ControllerBase - { - private readonly IBookRepo _repository; - - public InventarController(IBookRepo repository) - { - _repository = repository; - } - // GET Inventar - [HttpGet] - public ActionResult> GetAllItems() - { - var items = _repository.GetAllItems(); - return Ok(items); - } - - // POST Inventar - [HttpPost] - public ActionResult> NewItem(Item item) - { - return Ok(new Item - { - Id = item.Id, - BookId = book.ProductId, - }); - } - - - // GET Inventar/{id} - [HttpGet("{id}", Name = "GetItemByID")] - public ActionResult> GetItemByID(int id) - { - var item = _repository.GetItemById(id); - if (item != null) - { - return Ok(item); - } - return NoContent(); - - } - - - // DELETE inventory/{id} - [HttpDelete("id")] - public ActionResult> DeleteItem(int id) - { - var item = _repository.GetItemById(id); - if (item == null) - { - return NotFound(); - } - _repository.DeleteItem(Item); - return NoContent(); - } - - } - -} diff --git a/Controllers/LendController.cs b/Controllers/LendController.cs deleted file mode 100644 index 136b429..0000000 --- a/Controllers/LendController.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using AutoMapper; -using BuecherwurmAPI.Data; -using BuecherwurmAPI.DTOs; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.JsonPatch; -using Microsoft.Extensions.Logging; -using BuecherwurmAPI.Models; - -namespace BuecherwurmAPI.Controllers -{ - [Route("api/leihvorgang")] - [ApiController] - public class LendController : ControllerBase - { - private readonly ILendRepo _repository; - private readonly IMapper _mapper; - - public LendController(ILendRepo repository, IMapper mapper) - { - _repository = repository; - _mapper = mapper; - } - - //GET api/leihvorgang - [HttpGet] - public ActionResult> LendsGet() - { - return Ok(_repository.GetAllLends()); - } - - //POST api/leihvorgang - [HttpPost] - public ActionResult LendsPost(Lend lend) - { - /* - Internally a lend is stored with an id - but the client shouldn't be allowed to set or change it - therefore the package 'AutoMapper' is used to prevent errors - that could happen when doing this task manually. - It takes the information from the client and maps it to the - corresponding internal object which then will be returned. - Furthermore it could be used to keep some attributes secret. - Another nice effect of this is that the implementation could be changed - while the interface could be retained by some minor changes in the code. - - DTO stands for Data Transfer Object - */ - var item = new Lend - { - Id = 256, - Customer = lend.Customer, - Returned = lend.Returned, - ItemId = lend.ItemId, - ReturnDate = lend.ReturnDate - }; - return Ok(item); - //return Ok(_mapper.Map(item)); - } - - //GET api/leihvorgang/{id} - [HttpGet("{id}")] - public ActionResult LendById(int id) - { - var lend = _repository.GetLendById(id); - return Ok(lend); - } - - //PATCH api/leihvorgang/{id} - [HttpPatch("{id}")] - public ActionResult LendPatchById(int id, JsonPatchDocument patchDocument) - { - var lend = _repository.GetLendById(id); - if (lend == null) - { - return NotFound(); - } - return Ok(); - } - } -} diff --git a/DTOs/LendRead.cs b/DTOs/LendRead.cs deleted file mode 100644 index 5813213..0000000 --- a/DTOs/LendRead.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace BuecherwurmAPI.DTOs -{ - public class LendReadDTO - { - public int ItemId { get; set;} - public DateTime ReturnDate { get; set; } - public string Customer { get; set; } - public bool Returned { get; set; } - } -} \ No newline at end of file diff --git a/Data/ILendRepo.cs b/Data/ILendRepo.cs deleted file mode 100644 index d392ae6..0000000 --- a/Data/ILendRepo.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using BuecherwurmAPI.Models; - -namespace BuecherwurmAPI.Data -{ - public interface ILendRepo - { - IEnumerable GetAllLends(); - Lend GetLendById(int id); - } -} \ No newline at end of file diff --git a/Data/MockLendRepo.cs b/Data/MockLendRepo.cs deleted file mode 100644 index 717342c..0000000 --- a/Data/MockLendRepo.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using BuecherwurmAPI.Models; - -namespace BuecherwurmAPI.Data -{ - public class MockLendRepo : ILendRepo - { - public IEnumerable GetAllLends() - { - var lends = new List - { - 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}; - } - } -} \ No newline at end of file diff --git a/Models/Item.cs b/Models/Item.cs deleted file mode 100644 index c6e6012..0000000 --- a/Models/Item.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace BuecherwurmAPI.Models -{ - public class Item - { - [Key] - [Required] - public int Id { get; set; } - [Required] - public int BookId { get; set; } - } - -} \ No newline at end of file diff --git a/Models/Lend.cs b/Models/Lend.cs deleted file mode 100644 index b740853..0000000 --- a/Models/Lend.cs +++ /dev/null @@ -1,13 +0,0 @@ -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; } - } -} \ No newline at end of file diff --git a/Profiles/LendProfile.cs b/Profiles/LendProfile.cs deleted file mode 100644 index 074931c..0000000 --- a/Profiles/LendProfile.cs +++ /dev/null @@ -1,14 +0,0 @@ -using AutoMapper; -using BuecherwurmAPI.DTOs; -using BuecherwurmAPI.Models; - -namespace BuecherwurmAPI.Profiles -{ - public class LendProfile : Profile - { - public LendProfile() - { - CreateMap(); - } - } -} \ No newline at end of file diff --git a/Program.cs b/Program.cs deleted file mode 100644 index e60685a..0000000 --- a/Program.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; - -namespace BuecherwurmAPI -{ - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } -} diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json deleted file mode 100644 index fa2e929..0000000 --- a/Properties/launchSettings.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "$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" - } - } - } -} diff --git a/Startup.cs b/Startup.cs deleted file mode 100644 index d9a3ef4..0000000 --- a/Startup.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -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; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; - -namespace BuecherwurmAPI -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - services.AddControllers(); - - // Adds a service that is created once per connection. - // It takes an interface and a specific implementation. - // That allows to swap the implementation easily. - services.AddScoped(); - - services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.UseHttpsRedirection(); - - app.UseRouting(); - - app.UseAuthorization(); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } -} diff --git a/appsettings.Development.json b/appsettings.Development.json deleted file mode 100644 index dba68eb..0000000 --- a/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/appsettings.json b/appsettings.json deleted file mode 100644 index 81ff877..0000000 --- a/appsettings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "AllowedHosts": "*" -}