Update: Benennungen angepasst - Copy --> Item

This commit is contained in:
David Renner 2020-05-28 10:38:21 +02:00
parent f76303a1cf
commit d827332311
3 changed files with 19 additions and 19 deletions

Binary file not shown.

View file

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

View file

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