From 7f5ca580c682a4b4edc708cd8bccf7733bdf70e9 Mon Sep 17 00:00:00 2001 From: David Renner Date: Thu, 28 May 2020 10:07:58 +0200 Subject: [PATCH] update - KatalogController kopiert, zu InventarController umgeschrieben --- .vs/BuecherwurmAPI/v16/.suo | Bin 3584 -> 7680 bytes .vs/slnx.sqlite | Bin 249856 -> 249856 bytes Controllers/InventarController.cs | 72 +++++++++++++++++++++++ Controllers/WeatherForecastController.cs | 39 ------------ WeatherForecast.cs | 15 ----- 5 files changed, 72 insertions(+), 54 deletions(-) create mode 100644 Controllers/InventarController.cs delete mode 100644 Controllers/WeatherForecastController.cs delete mode 100644 WeatherForecast.cs diff --git a/.vs/BuecherwurmAPI/v16/.suo b/.vs/BuecherwurmAPI/v16/.suo index 58b5fea2a9d31ec352bd728ea645a41752c0edfc..ab63203ea8c7eec4e6ff0f52a5cdfb0e075c1ca6 100644 GIT binary patch literal 7680 zcmeHLO-NKx6h1R*rDkUNQ$bJ=Mg@b>q!nmCqG=12BqACYIx|{gGlSz~Mhj^XZu-MT zQP9sq7bQV0q*9_Ff(p_itA&I?MMwqF%0*7!dGF2mW_iNZ=5rO>oLofgRGCRv}BlE7oywBPS%7WdIj76WNuKe_SipfyxM zF0}2`#irC<@+mE7bF;>((bMN2KDE9xrDI;V1gttpbWkU6pwB%dG zX%U|+UkA7m;PT@;J6?3 z|1^LIB@X@{HU9G;H|hU^`h&5P&B1XX;P-M=v;Q+a1Ff8%>>FPL{O#iJc8X+U#sPnt z+1~tZ;BPhe83P>mxxWN$HY)oNkC&lcj+!ftnU*ZZ(16zcqZl?-D}4W8?C?E-PpmdK zz~i|C(m+doNnlZg7V<-4QiN$CWR7ExB#M^&?I9~?4`Pwe_oz{w^0&_Nr% zMMjpdWq$+2|ETZ(agP6je7-9&4)j1N&hZ}^81c@gSH3*{517hn2ifQVd6DsG$J2(V z6PXZ~Fm@mpVguEUJV`s*K@<5NPRhbn!mZ;Y|F<=&@P12b0YHYM`> z>gN>C^xcs))p9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ohE9>b+N7x@0B~Kj3Q_b|G8(&YS4p?X{*q3M37$osB#;3MZ$|ZLX;{dR<&)8W++| z#Ftbshao(HdisYh(m6UrCMB3)t8E=`l^T=pQX zrCe3O@P}#&@P=lFiKYy6WsmVpI{Aa0vt0P9db^`aXzZgvBU6rFyEM=jaTjDUMkhqXnA5 z3G|68^sC$&LDzAs_+5M;N8B#_UNw)^ndwNe8nuU85H{387H{u3aKKE3g<8Uzx{}F6 zs?F>y{;wq8T@+TUnaoyTZC;$%Wq)v^s5=-?*Rwrl@=-IDNOz^o+Q9!_)WE0S%yuTy zCgrJR?0z$mK4_+DJ5pwAqBAW*>IP;-FHd^xh^Rj0jj(maaWtbz{wQ^*#!Gk+&*C_q z!eKlnch!_3uF)EM;6}v35(mQ$7CTsEqt&{y)hW}1_M;wf5Dt=q!p7s{D^HKFu(9zK HSIyGDe5N7S diff --git a/Controllers/InventarController.cs b/Controllers/InventarController.cs new file mode 100644 index 0000000..5c3df55 --- /dev/null +++ b/Controllers/InventarController.cs @@ -0,0 +1,72 @@ +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> GetAllCopies() + { + var copies = _repository.GetAllCopies(); + return Ok(copies); + } + + // POST Inventar + [HttpPost] + public ActionResult> NeuesExemplar(Copy copy) + { + + return Ok(new Copy + { + CopyId = copy.CopyId, + ProductId = book.ProductId, + LendTime = copy.LendTime, + LendType = copy.LendType + }); + } + + + // GET Inventar/{id} + [HttpGet("{id}", Name = "GetCopyByID")] + public ActionResult> GetCopyByID(int id) + { + var copy = _repository.GetCopyById(id); + if (copy != null) + { + return Ok(copy); + } + return NoContent(); + + } + + + // DELETE katalog/{id} + /*[HttpDelete("id")] + public ActionResult> BuchEntfernen(int id) + { + var book = _repository.GetBookById(id); + if (book == null) + { + return NotFound(); + } + _repository.BuchEntfernen(book); + return NoContent(); + }*/ + + } + +} diff --git a/Controllers/WeatherForecastController.cs b/Controllers/WeatherForecastController.cs deleted file mode 100644 index 74bac7e..0000000 --- a/Controllers/WeatherForecastController.cs +++ /dev/null @@ -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 _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/WeatherForecast.cs b/WeatherForecast.cs deleted file mode 100644 index 7046a72..0000000 --- a/WeatherForecast.cs +++ /dev/null @@ -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; } - } -}