From 9d19fa9b1455574f6ee9d6be8152af416ee65e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=B6nbach?= Date: Fri, 29 May 2020 12:12:09 +0200 Subject: [PATCH] Projekt repariert --- BuecherwurmAPI.csproj | 38 ------- Controllers/LendController.cs | 183 ++------------------------------- Properties/launchSettings.json | 30 ++++++ Startup.cs | 126 +---------------------- appsettings.Development.json | 9 ++ appsettings.json | 10 ++ 6 files changed, 56 insertions(+), 340 deletions(-) create mode 100644 Properties/launchSettings.json create mode 100644 appsettings.Development.json create mode 100644 appsettings.json diff --git a/BuecherwurmAPI.csproj b/BuecherwurmAPI.csproj index 7194583..f1755c4 100644 --- a/BuecherwurmAPI.csproj +++ b/BuecherwurmAPI.csproj @@ -1,4 +1,3 @@ -<<<<<<< HEAD @@ -20,40 +19,3 @@ -||||||| 22e87cd - - - - netcoreapp3.1 - - - - - - - - - -======= - - - - netcoreapp3.1 - - - - - - - - - - - - Always - - - - - ->>>>>>> 9738f3a239ed469853270f7334714b5cc40afe5c diff --git a/Controllers/LendController.cs b/Controllers/LendController.cs index 292b0a3..2c43a1a 100644 --- a/Controllers/LendController.cs +++ b/Controllers/LendController.cs @@ -1,5 +1,4 @@ -<<<<<<< HEAD -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -19,20 +18,20 @@ namespace BuecherwurmAPI.Controllers { private readonly IRepository _repository; private readonly IMapper _mapper; - + public LendController(IRepository 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) @@ -71,6 +70,7 @@ namespace BuecherwurmAPI.Controllers { return NotFound(); } + return Ok(lend); } @@ -81,175 +81,4 @@ namespace BuecherwurmAPI.Controllers return Ok(); } } -} -||||||| 22e87cd -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(); - } - } -} -======= -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(); - } - } -} ->>>>>>> 9738f3a239ed469853270f7334714b5cc40afe5c +} \ No newline at end of file diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..fa2e929 --- /dev/null +++ b/Properties/launchSettings.json @@ -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" + } + } + } +} diff --git a/Startup.cs b/Startup.cs index 8436531..fe2f200 100644 --- a/Startup.cs +++ b/Startup.cs @@ -1,4 +1,3 @@ -<<<<<<< HEAD using System; using System.Collections.Generic; using System.Linq; @@ -58,127 +57,4 @@ namespace BuecherwurmAPI }); } } -} -||||||| 22e87cd -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(); - }); - } - } -} -======= -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(); - }); - } - } -} ->>>>>>> 9738f3a239ed469853270f7334714b5cc40afe5c +} \ No newline at end of file diff --git a/appsettings.Development.json b/appsettings.Development.json new file mode 100644 index 0000000..dba68eb --- /dev/null +++ b/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..81ff877 --- /dev/null +++ b/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +}