Update: Benennungen angepasst - Copy --> Item

InventarDavid
David Renner 2 years ago
parent f76303a1cf
commit d827332311
  1. BIN
      .vs/slnx.sqlite
  2. 32
      Controllers/InventarController.cs
  3. 6
      Models/Item.cs

Binary file not shown.

@ -19,32 +19,32 @@ namespace BuecherwurmAPI.Controllers
}
// GET Inventar
[HttpGet]
public ActionResult<IEnumerable<Copy>> GetAllCopies()
public ActionResult<IEnumerable<Item>> GetAllItems()
{
var copies = _repository.GetAllCopies();
return Ok(copies);
var items = _repository.GetAllItems();
return Ok(items);
}
// POST Inventar
[HttpPost]
public ActionResult<IEnumerable<Copy>> NeuesExemplar(Copy copy)
public ActionResult<IEnumerable<Item>> NewItem(Item item)
{
return Ok(new Copy
return Ok(new Item
{
CopyId = copy.CopyId,
ProductId = book.ProductId,
Id = item.Id,
BookId = book.ProductId,
});
}
// GET Inventar/{id}
[HttpGet("{id}", Name = "GetCopyByID")]
public ActionResult<IEnumerable<Copy>> GetCopyByID(int id)
[HttpGet("{id}", Name = "GetItemByID")]
public ActionResult<IEnumerable<Item>> GetItemByID(int id)
{
var copy = _repository.GetCopyById(id);
if (copy != null)
var item = _repository.GetItemById(id);
if (item != null)
{
return Ok(copy);
return Ok(item);
}
return NoContent();
@ -53,14 +53,14 @@ namespace BuecherwurmAPI.Controllers
// DELETE inventory/{id}
[HttpDelete("id")]
public ActionResult<IEnumerable<Copy>> ExemplarEntfernen(int id)
public ActionResult<IEnumerable<Item>> DeleteItem(int id)
{
var copy = _repository.GetCopyById(id);
if (copy == null)
var item = _repository.GetItemById(id);
if (item == null)
{
return NotFound();
}
_repository.ExemplarEntfernen(copy);
_repository.DeleteItem(Item);
return NoContent();
}

@ -2,13 +2,13 @@ using System.ComponentModel.DataAnnotations;
namespace BuecherwurmAPI.Models
{
public class Copy
public class Item
{
[Key]
[Required]
public int CopyId { get; set; }
public int Id { get; set; }
[Required]
public int ProductId { get; set; }
public int BookId { get; set; }
}
}
Loading…
Cancel
Save