From 226faafafcf6537e5594e6deb547ee5af945d606 Mon Sep 17 00:00:00 2001 From: Naumann Date: Wed, 3 Jun 2020 07:37:37 +0200 Subject: [PATCH] added new Methodes to KatalogModel --- Models/KatalogModel.cs | 16 ++++++++++++++-- Models/Lend.cs | 3 +++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Models/KatalogModel.cs b/Models/KatalogModel.cs index 6fcb3c1..7e28488 100644 --- a/Models/KatalogModel.cs +++ b/Models/KatalogModel.cs @@ -76,12 +76,24 @@ namespace BuecherwurmAPI.Models } public void DeleteBook(Book book) { - + using (var command = _dbConnection.CreateCommand()) + { + // funktioniert das so? + command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = book.ProductId; + command.CommandText = @"DELETE * FROM Books WHERE ProductId= @id"; + var dataReader = command.ExecuteReader(); + } } public void AddBook (Book book) { - + using (var command = _dbConnection.CreateCommand()) + { + // funktioniert das so? + command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = book.ProductId; + command.CommandText = @"INSERT INTO Books (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType) "; + var dataReader = command.ExecuteReader(); + } } public void EditBook (Book book) diff --git a/Models/Lend.cs b/Models/Lend.cs index d2e7954..5bd643b 100644 --- a/Models/Lend.cs +++ b/Models/Lend.cs @@ -1,9 +1,12 @@ using System; +using System.ComponentModel.DataAnnotations; namespace BuecherwurmAPI.Models { public class Lend { + [Key] + [Required] public long Id { get; set; } public long ItemId { get; set;} public DateTime ReturnDate { get; set; }