From 1637f45d0e793aa4e188353ce1618101c6a52f38 Mon Sep 17 00:00:00 2001 From: Naumann Date: Tue, 2 Jun 2020 12:55:17 +0200 Subject: [PATCH 01/11] Added KatalogModel --- Controllers/KatalogController.cs | 10 ++-- Models/Book.cs | 8 +-- Models/IBookRepo.cs | 6 ++- Models/KatalogModel.cs | 93 ++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 11 deletions(-) create mode 100644 Models/KatalogModel.cs diff --git a/Controllers/KatalogController.cs b/Controllers/KatalogController.cs index 6bb34e4..d7c4d52 100644 --- a/Controllers/KatalogController.cs +++ b/Controllers/KatalogController.cs @@ -26,7 +26,7 @@ namespace BuecherwurmAPI.Controllers // POST Katalog [HttpPost] - public ActionResult> NeuesBuch(Book book) + public ActionResult> AddBook(Book book) { return Ok(new Book @@ -49,7 +49,7 @@ namespace BuecherwurmAPI.Controllers // GET katalog/{id} [HttpGet("{id}", Name ="GetBookByID")] - public ActionResult > GetBookByID(int id) + public ActionResult > GetBookByID(long id) { var book = _repository.GetBookById(id); if (book != null) @@ -62,7 +62,7 @@ namespace BuecherwurmAPI.Controllers // PUT Katalog/{id} [HttpPut("id")] - public ActionResult> BuchBearbeiten(Book book) + public ActionResult> EditBook(Book book) { return Ok(new Book { @@ -83,14 +83,14 @@ namespace BuecherwurmAPI.Controllers // DELETE katalog/{id} [HttpDelete("id")] - public ActionResult> BuchEntfernen (int id) + public ActionResult> DeleteBook (long id) { var book = _repository.GetBookById(id); if(book == null) { return NotFound(); } - _repository.BuchEntfernen(book); + _repository.DeleteBook(book); return NoContent(); } diff --git a/Models/Book.cs b/Models/Book.cs index 5304bdc..bc90fd5 100644 --- a/Models/Book.cs +++ b/Models/Book.cs @@ -9,14 +9,14 @@ namespace BuecherwurmAPI.Models public string Country {get; set;} public string Link {get; set;} public string Language {get; set;} - public int Pages {get; set;} - public int Year {get; set;} + public long Pages {get; set;} + public long Year {get; set;} [Key] [Required] - public int ProductId { get; set; } + public long ProductId { get; set; } public CategoryEnum Category { get; set; } public string ImageLink { get; set; } - public int LendTime {get; set;} + public long LendTime {get; set;} public LendTypeEnum LendType {get; set;} } diff --git a/Models/IBookRepo.cs b/Models/IBookRepo.cs index 30fea50..9d4aca2 100644 --- a/Models/IBookRepo.cs +++ b/Models/IBookRepo.cs @@ -6,7 +6,9 @@ namespace BuecherwurmAPI.Models public interface IBookRepo { IEnumerable GetAllBooks(); - Book GetBookById(int id); - void BuchEntfernen(Book book); + Book GetBookById(long id); + void DeleteBook(Book book); + void AddBook (Book book); + void EditBook (Book book); } } \ No newline at end of file diff --git a/Models/KatalogModel.cs b/Models/KatalogModel.cs new file mode 100644 index 0000000..6fcb3c1 --- /dev/null +++ b/Models/KatalogModel.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using BuecherwurmAPI.Models; +using Microsoft.Data.Sqlite; +using Microsoft.VisualBasic.CompilerServices; + +namespace BuecherwurmAPI.Models +{ + internal class Katalog : IBookRepo + { + private SqliteConnection _dbConnection; + + public Katalog() + { + var connectionBuilder = new SqliteConnectionStringBuilder {DataSource = "LongWormMemory.db"}; + _dbConnection = new SqliteConnection(connectionBuilder.ConnectionString); + _dbConnection.Open(); + } + + public IEnumerable GetAllBooks() + { + var books= new List(); + + using (var command = _dbConnection.CreateCommand()) + { + command.CommandText = @"SELECT * FROM Books"; + var dataReader = command.ExecuteReader(); + + while (dataReader.Read()) + { + books.Add(new Book + { + Name = (string) dataReader["Books"], + Author = (string) dataReader["Author"], + Country = (string) dataReader["Country"], + Link = (string) dataReader["Link"], + Language = (string) dataReader["Language"], + Pages = (long) dataReader["Pages"], + Year = (long) dataReader["Year"], + ProductId = (long) dataReader["ProductId"], + Category = (CategoryEnum) dataReader["Category"], + ImageLink = (string) dataReader["ImageLink"], + LendTime = (long) dataReader["LendTime"], + LendType = (LendTypeEnum) dataReader["LendType"] + }); + } + } + return books; + } + + public Book GetBookById(long id) + { + using (var command = _dbConnection.CreateCommand()) + { + command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = id; + command.CommandText = @"SELECT * FROM Books WHERE ProductId = @id"; + var dataReader = command.ExecuteReader(); + + var book = new Book + { + Name = (string) dataReader["Books"], + Author = (string) dataReader["Author"], + Country = (string) dataReader["Country"], + Link = (string) dataReader["Link"], + Language = (string) dataReader["Language"], + Pages = (long) dataReader["Pages"], + Year = (long) dataReader["Year"], + ProductId = (long) dataReader["ProductId"], + Category = (CategoryEnum) dataReader["Category"], + ImageLink = (string) dataReader["ImageLink"], + LendTime = (long) dataReader["LendTime"], + LendType = (LendTypeEnum) dataReader["LendType"] + }; + return book; + } + } + public void DeleteBook(Book book) + { + + } + + public void AddBook (Book book) + { + + } + + public void EditBook (Book book) + { + + } + + } +} \ No newline at end of file From 226faafafcf6537e5594e6deb547ee5af945d606 Mon Sep 17 00:00:00 2001 From: Naumann Date: Wed, 3 Jun 2020 07:37:37 +0200 Subject: [PATCH 02/11] 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; } From a1ffee2e09e11a1c23e66026128b9b912a69f5af Mon Sep 17 00:00:00 2001 From: Naumann Date: Wed, 3 Jun 2020 07:59:31 +0200 Subject: [PATCH 03/11] fixed AddBook and EditBook --- Controllers/KatalogController.cs | 2 +- Models/IBookRepo.cs | 4 ++-- Models/KatalogModel.cs | 17 +++++++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Controllers/KatalogController.cs b/Controllers/KatalogController.cs index d7c4d52..63fb7be 100644 --- a/Controllers/KatalogController.cs +++ b/Controllers/KatalogController.cs @@ -90,7 +90,7 @@ namespace BuecherwurmAPI.Controllers { return NotFound(); } - _repository.DeleteBook(book); + _repository.DeleteBook(id); return NoContent(); } diff --git a/Models/IBookRepo.cs b/Models/IBookRepo.cs index 9d4aca2..bd13521 100644 --- a/Models/IBookRepo.cs +++ b/Models/IBookRepo.cs @@ -7,8 +7,8 @@ namespace BuecherwurmAPI.Models { IEnumerable GetAllBooks(); Book GetBookById(long id); - void DeleteBook(Book book); + void DeleteBook(long id); void AddBook (Book book); - void EditBook (Book book); + void EditBook (long id, Book book); } } \ No newline at end of file diff --git a/Models/KatalogModel.cs b/Models/KatalogModel.cs index 7e28488..f5e5823 100644 --- a/Models/KatalogModel.cs +++ b/Models/KatalogModel.cs @@ -74,12 +74,12 @@ namespace BuecherwurmAPI.Models return book; } } - public void DeleteBook(Book book) + public void DeleteBook(long id) { using (var command = _dbConnection.CreateCommand()) { // funktioniert das so? - command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = book.ProductId; + command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = id; command.CommandText = @"DELETE * FROM Books WHERE ProductId= @id"; var dataReader = command.ExecuteReader(); } @@ -90,15 +90,20 @@ namespace BuecherwurmAPI.Models 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) "; + command.CommandText = @"INSERT INTO Books (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType) VALUES (book.Name, book.Author, book.Contry, book.Link, book.Language, book.Pages, book.Year, book.ProductId, book.Category, book.ImageLink, book.LendTime, book.LendType)"; var dataReader = command.ExecuteReader(); } } - public void EditBook (Book book) + public void EditBook (long id, Book book) { - + using (var command = _dbConnection.CreateCommand()) + { + // funktioniert das so? + command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = id; + command.CommandText = @"INSERT INTO Books (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType)VALUES (book.Name, book.Author, book.Contry, book.Link, book.Language, book.Pages, book.Year, book.ProductId, book.Category, book.ImageLink, book.LendTime, book.LendType) WHERE ProductId = @id"; + var dataReader = command.ExecuteReader(); + } } } From a707f23dc244a65d0f5cc68f3d1304b6c6ac2ab8 Mon Sep 17 00:00:00 2001 From: nek0 Date: Wed, 3 Jun 2020 09:26:07 +0200 Subject: [PATCH 04/11] db connection meowdy meow --- Controllers/InventarController.cs | 10 ++++----- Controllers/LendController.cs | 34 +++++++++++++++++++------------ Models/ILendRepo.cs | 11 ---------- Models/IRepository.cs | 13 ------------ Models/Interfaces.cs | 9 ++++++++ Models/Item.cs | 3 +-- Models/Lend.cs | 15 ++++++++++++++ Models/LendModel.cs | 31 ++++++++++++++++++++++------ Startup.cs | 2 +- 9 files changed, 77 insertions(+), 51 deletions(-) delete mode 100644 Models/ILendRepo.cs delete mode 100644 Models/IRepository.cs create mode 100644 Models/Interfaces.cs diff --git a/Controllers/InventarController.cs b/Controllers/InventarController.cs index 5e8870d..2c5e5cd 100644 --- a/Controllers/InventarController.cs +++ b/Controllers/InventarController.cs @@ -27,16 +27,16 @@ namespace BuecherwurmAPI.Controllers // POST Inventar [HttpPost] - public ActionResult> NewItem(Item item) + public ActionResult> NewItem(int bookId) { + var itemid = insertItemReturningId(bookId); return Ok(new Item { - Id = item.Id, - BookId = item.BookId, + Id = itemId, + BookId = bookId, }); } - - + // GET Inventar/{id} [HttpGet("{id}", Name = "GetItemByID")] public ActionResult> GetItemByID(int id) diff --git a/Controllers/LendController.cs b/Controllers/LendController.cs index 813d893..b18ff9b 100644 --- a/Controllers/LendController.cs +++ b/Controllers/LendController.cs @@ -8,7 +8,7 @@ using BuecherwurmAPI.DTOs; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.JsonPatch; using Microsoft.Extensions.Logging; - +using Microsoft.Data.Sqlite; namespace BuecherwurmAPI.Controllers { @@ -16,12 +16,12 @@ namespace BuecherwurmAPI.Controllers [ApiController] public class LendController : ControllerBase { - private readonly IRepository _repository; + private readonly LendModel _repository; private readonly IMapper _mapper; - public LendController(IRepository repository, IMapper mapper) + public LendController(SqliteConnection connection, IMapper mapper) { - _repository = repository; + _repository = new LendModel(connection); _mapper = mapper; } @@ -34,7 +34,7 @@ namespace BuecherwurmAPI.Controllers //POST api/leihvorgang [HttpPost] - public ActionResult LendsPost(Lend lend) + public ActionResult LendsPost(LendSeed lend) { /* Internally a lend is stored with an id @@ -49,15 +49,23 @@ namespace BuecherwurmAPI.Controllers DTO stands for Data Transfer Object */ - var item = new Lend + var newId = _repository.insertLendReturningId(lend); + if (newId > 0) { - Id = 256, - Customer = lend.Customer, - Returned = lend.Returned, - ItemId = lend.ItemId, - ReturnDate = lend.ReturnDate - }; - return Ok(item); + var item = new Lend + { + Id = newId, + Customer = lend.Customer, + Returned = false, + ItemId = lend.ItemId, + ReturnDate = lend.ReturnDate + }; + return Ok(item); + } + else + { + return BadRequest(); + } //return Ok(_mapper.Map(item)); } diff --git a/Models/ILendRepo.cs b/Models/ILendRepo.cs deleted file mode 100644 index 9e12f99..0000000 --- a/Models/ILendRepo.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using BuecherwurmAPI.Models; - -namespace BuecherwurmAPI.Models -{ - public interface ILendRepo - { - IEnumerable GetAllLends(); - Lend GetLendById(int id); - } -} \ No newline at end of file diff --git a/Models/IRepository.cs b/Models/IRepository.cs deleted file mode 100644 index 6e79a2a..0000000 --- a/Models/IRepository.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; -using BuecherwurmAPI.Models; -using Microsoft.EntityFrameworkCore.Metadata.Conventions; - -namespace BuecherwurmAPI.Models -{ - public interface IRepository - { - IEnumerable GetAllLends(); - Lend GetLendById(long id); - bool IdExits(string table, long id); - } -} \ No newline at end of file diff --git a/Models/Interfaces.cs b/Models/Interfaces.cs new file mode 100644 index 0000000..64a6026 --- /dev/null +++ b/Models/Interfaces.cs @@ -0,0 +1,9 @@ +using Microsoft.Data.Sqlite; + +namespace BuecherwurmAPI.Models +{ + public interface IModel + { + + } +} \ No newline at end of file diff --git a/Models/Item.cs b/Models/Item.cs index c6e6012..17e6017 100644 --- a/Models/Item.cs +++ b/Models/Item.cs @@ -4,8 +4,7 @@ namespace BuecherwurmAPI.Models { public class Item { - [Key] - [Required] + [Key, Required] public int Id { get; set; } [Required] public int BookId { get; set; } diff --git a/Models/Lend.cs b/Models/Lend.cs index d2e7954..6c258f2 100644 --- a/Models/Lend.cs +++ b/Models/Lend.cs @@ -1,13 +1,28 @@ using System; +using System.ComponentModel.DataAnnotations; namespace BuecherwurmAPI.Models { public class Lend { + [Key, Required] public long Id { get; set; } + [Required] public long ItemId { get; set;} + [Required] public DateTime ReturnDate { get; set; } + [Required] public string Customer { get; set; } + [Required] public bool Returned { get; set; } } + + public class LendSeed + { + public long ItemId {get; set;} + + public DateTime ReturnDate {get; set;} + + public string Customer {get; set;} + } } diff --git a/Models/LendModel.cs b/Models/LendModel.cs index c69942a..014ac36 100644 --- a/Models/LendModel.cs +++ b/Models/LendModel.cs @@ -6,15 +6,13 @@ using Microsoft.VisualBasic.CompilerServices; namespace BuecherwurmAPI.Models { - internal class Repository : IRepository + internal class LendModel : IModel { - private SqliteConnection _dbConnection; + public SqliteConnection _dbConnection; - public Repository() + public LendModel(SqliteConnection connection) { - var connectionBuilder = new SqliteConnectionStringBuilder {DataSource = "LongWormMemory.db"}; - _dbConnection = new SqliteConnection(connectionBuilder.ConnectionString); - _dbConnection.Open(); + _dbConnection = connection; } public bool IdExits(string table, long id) @@ -94,5 +92,26 @@ namespace BuecherwurmAPI.Models } return null; } + + public long insertLendReturningId(LendSeed lend) + { + using (var command = _dbConnection.CreateCommand()) + { + command.CommandText = "INSERT INTO Lends VALUES (NULL, @itemId, @returnDate, @customer, false)"; + command.Parameters.Add(new SqliteParameter("@itemId", lend.ItemId)); + command.Parameters.Add(new SqliteParameter("@returnDate", lend.ReturnDate)); + command.Parameters.Add(new SqliteParameter("@customer", lend.Customer)); + + var success = command.ExecuteNonQuery(); + + if (success == 1) + { + command.CommandText = @"SELECT last_insert_rowid()"; + return (long)command.ExecuteScalar(); + } + + return -1; + } + } } } \ No newline at end of file diff --git a/Startup.cs b/Startup.cs index b6cc4f5..c17f544 100644 --- a/Startup.cs +++ b/Startup.cs @@ -32,7 +32,7 @@ namespace BuecherwurmAPI // 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.AddScoped(); services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); } From 67eb721d3899ccce3709c6274c2bc4665362816c Mon Sep 17 00:00:00 2001 From: Naumann Date: Wed, 3 Jun 2020 09:41:45 +0200 Subject: [PATCH 05/11] zwischenstand --- Models/KatalogModel.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Models/KatalogModel.cs b/Models/KatalogModel.cs index f5e5823..b8a794d 100644 --- a/Models/KatalogModel.cs +++ b/Models/KatalogModel.cs @@ -91,7 +91,20 @@ namespace BuecherwurmAPI.Models { // funktioniert das so? command.CommandText = @"INSERT INTO Books (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType) VALUES (book.Name, book.Author, book.Contry, book.Link, book.Language, book.Pages, book.Year, book.ProductId, book.Category, book.ImageLink, book.LendTime, book.LendType)"; - var dataReader = command.ExecuteReader(); + + command.Parameters.Add(new SqliteParameter("@itemId", lend.ItemId)); + command.Parameters.Add(new SqliteParameter("@returnDate", lend.ReturnDate)); + command.Parameters.Add(new SqliteParameter("@customer", lend.Customer)); + + var success = command.ExecuteNonQuery(); + + if (success == 1) + { + command.CommandText = @"SELECT last_insert_rowid()"; + return (long)command.ExecuteScalar(); + } + + return -1; } } From ae3cbb0cd3aa66f0cde03225a99cdd77c6c29729 Mon Sep 17 00:00:00 2001 From: Naumann Date: Wed, 3 Jun 2020 10:19:45 +0200 Subject: [PATCH 06/11] . --- Controllers/InventarController.cs | 2 +- Models/IBookRepo.cs | 4 +-- Models/KatalogModel.cs | 49 +++++++++++++++++++++++++------ 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/Controllers/InventarController.cs b/Controllers/InventarController.cs index 2c5e5cd..6f3495e 100644 --- a/Controllers/InventarController.cs +++ b/Controllers/InventarController.cs @@ -32,7 +32,7 @@ namespace BuecherwurmAPI.Controllers var itemid = insertItemReturningId(bookId); return Ok(new Item { - Id = itemId, + Id = itemid, BookId = bookId, }); } diff --git a/Models/IBookRepo.cs b/Models/IBookRepo.cs index bd13521..2bf60e9 100644 --- a/Models/IBookRepo.cs +++ b/Models/IBookRepo.cs @@ -8,7 +8,7 @@ namespace BuecherwurmAPI.Models IEnumerable GetAllBooks(); Book GetBookById(long id); void DeleteBook(long id); - void AddBook (Book book); - void EditBook (long id, Book book); + long AddBook (Book book); + long EditBook (long id, Book book); } } \ No newline at end of file diff --git a/Models/KatalogModel.cs b/Models/KatalogModel.cs index b8a794d..e1dd357 100644 --- a/Models/KatalogModel.cs +++ b/Models/KatalogModel.cs @@ -78,23 +78,32 @@ namespace BuecherwurmAPI.Models { using (var command = _dbConnection.CreateCommand()) { - // funktioniert das so? command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = id; command.CommandText = @"DELETE * FROM Books WHERE ProductId= @id"; var dataReader = command.ExecuteReader(); } } - public void AddBook (Book book) + public long AddBook (Book book) { using (var command = _dbConnection.CreateCommand()) { // funktioniert das so? - command.CommandText = @"INSERT INTO Books (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType) VALUES (book.Name, book.Author, book.Contry, book.Link, book.Language, book.Pages, book.Year, book.ProductId, book.Category, book.ImageLink, book.LendTime, book.LendType)"; + //muss ProduktId übergeben werden? + command.CommandText = @"INSERT INTO Books (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType) VALUES (@Name, @Author, @Country, @Link, @Language, @Pages, @Year, @ProductId, @Category, @ImageLink, @LendTime, @LendType )"; - command.Parameters.Add(new SqliteParameter("@itemId", lend.ItemId)); - command.Parameters.Add(new SqliteParameter("@returnDate", lend.ReturnDate)); - command.Parameters.Add(new SqliteParameter("@customer", lend.Customer)); + command.Parameters.Add(new SqliteParameter("@Name", book.Name)); + command.Parameters.Add(new SqliteParameter("@Author", book.Author)); + command.Parameters.Add(new SqliteParameter("@Contry", book.Country)); + command.Parameters.Add(new SqliteParameter("@Link", book.Link)); + command.Parameters.Add(new SqliteParameter("@Language", book.Language)); + command.Parameters.Add(new SqliteParameter("@Pages", book.Pages)); + command.Parameters.Add(new SqliteParameter("@Year", book.Year)); + command.Parameters.Add(new SqliteParameter("@ProductId", book.ProductId)); + command.Parameters.Add(new SqliteParameter("@Category", book.Category)); + command.Parameters.Add(new SqliteParameter("@ImageLink", book.ImageLink)); + command.Parameters.Add(new SqliteParameter("@LendTime", book.LendTime)); + command.Parameters.Add(new SqliteParameter("@LendType", book.LendType)); var success = command.ExecuteNonQuery(); @@ -108,14 +117,36 @@ namespace BuecherwurmAPI.Models } } - public void EditBook (long id, Book book) + public long EditBook (long id, Book book) { using (var command = _dbConnection.CreateCommand()) { // funktioniert das so? command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = id; - command.CommandText = @"INSERT INTO Books (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType)VALUES (book.Name, book.Author, book.Contry, book.Link, book.Language, book.Pages, book.Year, book.ProductId, book.Category, book.ImageLink, book.LendTime, book.LendType) WHERE ProductId = @id"; - var dataReader = command.ExecuteReader(); + command.CommandText = @"INSERT INTO Books (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType) VALUES (@Name, @Author, @Country, @Link, @Language, @Pages, @Year, @ProductId, @Category, @ImageLink, @LendTime, @LendType )"; + + command.Parameters.Add(new SqliteParameter("@Name", book.Name)); + command.Parameters.Add(new SqliteParameter("@Author", book.Author)); + command.Parameters.Add(new SqliteParameter("@Contry", book.Country)); + command.Parameters.Add(new SqliteParameter("@Link", book.Link)); + command.Parameters.Add(new SqliteParameter("@Language", book.Language)); + command.Parameters.Add(new SqliteParameter("@Pages", book.Pages)); + command.Parameters.Add(new SqliteParameter("@Year", book.Year)); + command.Parameters.Add(new SqliteParameter("@ProductId", book.ProductId)); + command.Parameters.Add(new SqliteParameter("@Category", book.Category)); + command.Parameters.Add(new SqliteParameter("@ImageLink", book.ImageLink)); + command.Parameters.Add(new SqliteParameter("@LendTime", book.LendTime)); + command.Parameters.Add(new SqliteParameter("@LendType", book.LendType)); + + var success = command.ExecuteNonQuery(); + + if (success == 1) + { + command.CommandText = @"SELECT last_insert_rowid()"; + return (long)command.ExecuteScalar(); + } + + return -1; } } From 1d492652306a05677cda7ea232e559c761427406 Mon Sep 17 00:00:00 2001 From: nek0 Date: Wed, 3 Jun 2020 10:45:54 +0200 Subject: [PATCH 07/11] make items queryable --- Controllers/ItemController.cs | 16 ++++++++-------- Controllers/LendController.cs | 4 ++-- DTOs/LendRead.cs | 1 - LongWormMemory.db | Bin 12288 -> 12288 bytes Models/ItemModel.cs | 2 +- Models/LendModel.cs | 6 ++++-- Startup.cs | 1 + 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Controllers/ItemController.cs b/Controllers/ItemController.cs index 33d1135..83506c0 100644 --- a/Controllers/ItemController.cs +++ b/Controllers/ItemController.cs @@ -8,17 +8,17 @@ using Microsoft.Data.Sqlite; namespace BuecherwurmAPI.Controllers { - [Route("inventar")] + [Route("api/inventar")] [ApiController] public class ItemController : ControllerBase { - private readonly IItemRepo _repository; + private readonly ItemModel _repository; - public ItemController(IItemRepo repository) + public ItemController(IModel repository) { - _repository = repository; + _repository = (ItemModel)repository; } - // GET Inventar + // GET api/inventar [HttpGet] public ActionResult> GetAllItems() { @@ -26,7 +26,7 @@ namespace BuecherwurmAPI.Controllers return Ok(items); } - // POST Inventar + // POST api/inventar [HttpPost] public ActionResult> NewItem(ItemPost item) @@ -36,7 +36,7 @@ namespace BuecherwurmAPI.Controllers } - // GET Inventar/{id} + // GET api/nventar/{id} [HttpGet("{itemId}")] public ActionResult> GetItemByID(long id) { @@ -48,7 +48,7 @@ namespace BuecherwurmAPI.Controllers return NoContent(); } - // DELETE inventory/{id} + // DELETE api/inventar/{id} [HttpDelete("itemId")] public ActionResult> DeleteItem(long itemId) diff --git a/Controllers/LendController.cs b/Controllers/LendController.cs index b18ff9b..6ec0b63 100644 --- a/Controllers/LendController.cs +++ b/Controllers/LendController.cs @@ -19,9 +19,9 @@ namespace BuecherwurmAPI.Controllers private readonly LendModel _repository; private readonly IMapper _mapper; - public LendController(SqliteConnection connection, IMapper mapper) + public LendController(IModel repo, IMapper mapper) { - _repository = new LendModel(connection); + _repository = (LendModel)repo; _mapper = mapper; } diff --git a/DTOs/LendRead.cs b/DTOs/LendRead.cs index 5813213..0d39ee9 100644 --- a/DTOs/LendRead.cs +++ b/DTOs/LendRead.cs @@ -7,6 +7,5 @@ namespace BuecherwurmAPI.DTOs public int ItemId { get; set;} public DateTime ReturnDate { get; set; } public string Customer { get; set; } - public bool Returned { get; set; } } } \ No newline at end of file diff --git a/LongWormMemory.db b/LongWormMemory.db index 4b1deb5d1a8e635edc1c9c4ffcc9d800974024f1..c66591815d402591565ca39ff11d5f3689865e2c 100644 GIT binary patch delta 96 zcmZojXh@hK&B#7c##xY^LC-{imw|zSk>8Mk-;mE`Go!#Y-py`&`viGd_&r$oFY?dk v&*JykETCY)ucW}j#=vPT&0%C(); + services.AddScoped(); services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); } From f970ccc07e42333f2fbec5670e5a7a953a3464fe Mon Sep 17 00:00:00 2001 From: nek0 Date: Wed, 3 Jun 2020 10:55:39 +0200 Subject: [PATCH 08/11] removed obsolete DTOs --- Controllers/LendController.cs | 15 +-------------- DTOs/ItemRead.cs | 9 --------- DTOs/LendRead.cs | 11 ----------- Models/Item.cs | 1 - Models/Lend.cs | 2 +- Models/LendModel.cs | 2 +- 6 files changed, 3 insertions(+), 37 deletions(-) delete mode 100644 DTOs/ItemRead.cs delete mode 100644 DTOs/LendRead.cs diff --git a/Controllers/LendController.cs b/Controllers/LendController.cs index 6ec0b63..24f20b6 100644 --- a/Controllers/LendController.cs +++ b/Controllers/LendController.cs @@ -34,21 +34,8 @@ namespace BuecherwurmAPI.Controllers //POST api/leihvorgang [HttpPost] - public ActionResult LendsPost(LendSeed lend) + public ActionResult LendsPost(LendPost 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 newId = _repository.insertLendReturningId(lend); if (newId > 0) { diff --git a/DTOs/ItemRead.cs b/DTOs/ItemRead.cs deleted file mode 100644 index e70a016..0000000 --- a/DTOs/ItemRead.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace BuecherwurmAPI.DTOs -{ - public class ItemReadDTO - { - public int BookId { get; set;} - } -} \ No newline at end of file diff --git a/DTOs/LendRead.cs b/DTOs/LendRead.cs deleted file mode 100644 index 0d39ee9..0000000 --- a/DTOs/LendRead.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace BuecherwurmAPI.DTOs -{ - public class LendReadDTO - { - public int ItemId { get; set;} - public DateTime ReturnDate { get; set; } - public string Customer { get; set; } - } -} \ No newline at end of file diff --git a/Models/Item.cs b/Models/Item.cs index 2726273..dbff417 100644 --- a/Models/Item.cs +++ b/Models/Item.cs @@ -13,5 +13,4 @@ namespace BuecherwurmAPI.Models { public int BookId { get; set; } } - } \ No newline at end of file diff --git a/Models/Lend.cs b/Models/Lend.cs index 6c258f2..50ba663 100644 --- a/Models/Lend.cs +++ b/Models/Lend.cs @@ -17,7 +17,7 @@ namespace BuecherwurmAPI.Models public bool Returned { get; set; } } - public class LendSeed + public class LendPost { public long ItemId {get; set;} diff --git a/Models/LendModel.cs b/Models/LendModel.cs index 80076f4..1a0f5c1 100644 --- a/Models/LendModel.cs +++ b/Models/LendModel.cs @@ -95,7 +95,7 @@ namespace BuecherwurmAPI.Models return null; } - public long insertLendReturningId(LendSeed lend) + public long insertLendReturningId(LendPost lend) { using (var command = _dbConnection.CreateCommand()) { From da74cbc6d5b523361481fd35668741212ed34f2c Mon Sep 17 00:00:00 2001 From: Naumann Date: Wed, 3 Jun 2020 11:34:06 +0200 Subject: [PATCH 09/11] . --- Controllers/InventarController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controllers/InventarController.cs b/Controllers/InventarController.cs index 6f3495e..2c5e5cd 100644 --- a/Controllers/InventarController.cs +++ b/Controllers/InventarController.cs @@ -32,7 +32,7 @@ namespace BuecherwurmAPI.Controllers var itemid = insertItemReturningId(bookId); return Ok(new Item { - Id = itemid, + Id = itemId, BookId = bookId, }); } From 56e1cc14522b0786f9621b7e7cf58e0aa4bebd00 Mon Sep 17 00:00:00 2001 From: nek0 Date: Wed, 3 Jun 2020 11:34:12 +0200 Subject: [PATCH 10/11] reviewed, debugged and meowed with items --- Controllers/ItemController.cs | 4 ++-- Controllers/LendController.cs | 7 +++---- LongWormMemory.db | Bin 12288 -> 12288 bytes Models/Interfaces.cs | 9 --------- Models/ItemModel.cs | 14 ++++++++------ Models/LendModel.cs | 10 ++++++++-- Profiles/LendProfile.cs | 3 +-- Startup.cs | 4 ++-- 8 files changed, 24 insertions(+), 27 deletions(-) delete mode 100644 Models/Interfaces.cs diff --git a/Controllers/ItemController.cs b/Controllers/ItemController.cs index 83506c0..f4974e0 100644 --- a/Controllers/ItemController.cs +++ b/Controllers/ItemController.cs @@ -14,7 +14,7 @@ namespace BuecherwurmAPI.Controllers { private readonly ItemModel _repository; - public ItemController(IModel repository) + public ItemController(IItem repository) { _repository = (ItemModel)repository; } @@ -50,7 +50,7 @@ namespace BuecherwurmAPI.Controllers // DELETE api/inventar/{id} - [HttpDelete("itemId")] + [HttpDelete("{itemId}")] public ActionResult> DeleteItem(long itemId) { var item = _repository.GetItemById(itemId); diff --git a/Controllers/LendController.cs b/Controllers/LendController.cs index 24f20b6..f599103 100644 --- a/Controllers/LendController.cs +++ b/Controllers/LendController.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Threading.Tasks; using AutoMapper; using BuecherwurmAPI.Models; -using BuecherwurmAPI.DTOs; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.JsonPatch; using Microsoft.Extensions.Logging; @@ -17,12 +16,12 @@ namespace BuecherwurmAPI.Controllers public class LendController : ControllerBase { private readonly LendModel _repository; - private readonly IMapper _mapper; + //private readonly IMapper _mapper; - public LendController(IModel repo, IMapper mapper) + public LendController(ILend repo) { _repository = (LendModel)repo; - _mapper = mapper; + //_mapper = mapper; } //GET api/leihvorgang diff --git a/LongWormMemory.db b/LongWormMemory.db index c66591815d402591565ca39ff11d5f3689865e2c..d001dc19b76d9dab88aa3f056c23004368ba02ac 100644 GIT binary patch delta 265 zcmZojXh@hKEy&Bjz`zW|Fc2|O#~3K6XQBX-VdC4zz;DR6Z!@F7HQvc?d=>SDvh3pG z;*5=sC5cHnsh%aNxy4|D$vMc?F~n6N#L>yeRRJudpaG&hQxrV?LR{TlgB1MyLlpc% zeSCBjobvOtu}TC4dHOmAMJjl^MnZLKYBu`FfbDE5FG-wi%YT>)(); + CreateMap(); } } } \ No newline at end of file diff --git a/Startup.cs b/Startup.cs index 33779c4..1fc2f81 100644 --- a/Startup.cs +++ b/Startup.cs @@ -32,8 +32,8 @@ namespace BuecherwurmAPI // 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.AddScoped(); + services.AddScoped(); + services.AddScoped(); services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); } From ffd841b52626635d244f80e9049474e23f3acdfb Mon Sep 17 00:00:00 2001 From: nek0 Date: Wed, 3 Jun 2020 12:43:03 +0200 Subject: [PATCH 11/11] finalized catalogue --- Controllers/ItemController.cs | 6 ++--- Controllers/KatalogController.cs | 43 +++++++++++-------------------- LongWormMemory.db | Bin 12288 -> 16384 bytes Models/Book.cs | 18 +++++++++++-- Models/ItemModel.cs | 2 -- Models/KatalogModel.cs | 30 ++++++++++----------- Startup.cs | 1 + 7 files changed, 48 insertions(+), 52 deletions(-) diff --git a/Controllers/ItemController.cs b/Controllers/ItemController.cs index f4974e0..d089fb1 100644 --- a/Controllers/ItemController.cs +++ b/Controllers/ItemController.cs @@ -38,14 +38,14 @@ namespace BuecherwurmAPI.Controllers // GET api/nventar/{id} [HttpGet("{itemId}")] - public ActionResult> GetItemByID(long id) + public ActionResult> GetItemByID(long itemId) { - var item = _repository.GetItemById(id); + var item = _repository.GetItemById(itemId); if (item != null) { return Ok(item); } - return NoContent(); + return NotFound(); } // DELETE api/inventar/{id} diff --git a/Controllers/KatalogController.cs b/Controllers/KatalogController.cs index 63fb7be..0e4a68d 100644 --- a/Controllers/KatalogController.cs +++ b/Controllers/KatalogController.cs @@ -6,15 +6,15 @@ using System.Linq; namespace BuecherwurmAPI.Controllers { - [Route("katalog") ] + [Route("api/katalog") ] [ApiController] public class KatalogController :ControllerBase { - private readonly IBookRepo _repository; + private readonly KatalogModel _repository; - public KatalogController (IBookRepo repository) + public KatalogController (ICatalogue repository) { - _repository=repository; + _repository= (KatalogModel)repository; } // GET Katalog [HttpGet] @@ -26,9 +26,9 @@ namespace BuecherwurmAPI.Controllers // POST Katalog [HttpPost] - public ActionResult> AddBook(Book book) + public ActionResult AddBook(BookPost book) { - + var id = _repository.AddBook(book); return Ok(new Book { Name = book.Name, @@ -38,7 +38,7 @@ namespace BuecherwurmAPI.Controllers Language= book.Language, Pages= book.Pages, Year=book.Year, - ProductId =book.ProductId, + ProductId = id, Category= book.Category, ImageLink =book.ImageLink, LendTime =book.LendTime, @@ -48,8 +48,8 @@ namespace BuecherwurmAPI.Controllers // GET katalog/{id} - [HttpGet("{id}", Name ="GetBookByID")] - public ActionResult > GetBookByID(long id) + [HttpGet("{id}")] + public ActionResult GetBookByID(long id) { var book = _repository.GetBookById(id); if (book != null) @@ -61,29 +61,16 @@ namespace BuecherwurmAPI.Controllers } // PUT Katalog/{id} - [HttpPut("id")] - public ActionResult> EditBook(Book book) + [HttpPut("{id}")] + public ActionResult EditBook(long id, Book book) { - return Ok(new Book - { - Name = book.Name, - Author= book.Author, - Country= book.Country, - Link= book.Link, - Language= book.Language, - Pages= book.Pages, - Year=book.Year, - ProductId =book.ProductId, - Category= book.Category, - ImageLink =book.ImageLink, - LendTime =book.LendTime, - LendType = book.LendType - }); + _repository.EditBook(id, book); + return Ok(book); } // DELETE katalog/{id} - [HttpDelete("id")] - public ActionResult> DeleteBook (long id) + [HttpDelete("{id}")] + public ActionResult DeleteBook (long id) { var book = _repository.GetBookById(id); if(book == null) diff --git a/LongWormMemory.db b/LongWormMemory.db index d001dc19b76d9dab88aa3f056c23004368ba02ac..2af348abd5cc5350f02eaa525bfd54ec7a21f55d 100644 GIT binary patch delta 492 zcmZ8dK}!Nb7@c*LFjziML%Hnl|SVa?*SN8J)`(=l;>Vav4*zsofPYt2Z3 z9hVJ>m^+|B3D=1rZGkp^Z7AmbeT`a%&cqitipG)&oDFj@+KtwoRHJpZ*=wpIA@m6# zS^)Hc7U&BtW|{OG%D^}TNeD#|sU?yyG5g+w>Fs5P5}E=u6|xZBa!D>0^Jm#u3`lKB zI%gEuScjVU=)&e4Q;vzLsAk|Xf7s{TIW3nBMm>djT%pWTOc7R%2t({?>mB}ASa!F+ Ok(E2lG!)0`6=FXYy_9DF delta 88 zcmZo@U~EX3AT7wtz`(!^#4r#sQO6i4sAr-8l40W8$G~sMw{Nqcz%^bb#yt}o%Qo-h fb7tfO$}#f)X5jw~l)246ae^2VGvnsJ^2`DN%KZ~L diff --git a/Models/Book.cs b/Models/Book.cs index bc90fd5..3e605de 100644 --- a/Models/Book.cs +++ b/Models/Book.cs @@ -11,8 +11,7 @@ namespace BuecherwurmAPI.Models public string Language {get; set;} public long Pages {get; set;} public long Year {get; set;} - [Key] - [Required] + [Key, Required] public long ProductId { get; set; } public CategoryEnum Category { get; set; } public string ImageLink { get; set; } @@ -20,4 +19,19 @@ namespace BuecherwurmAPI.Models public LendTypeEnum LendType {get; set;} } + public class BookPost + { + public string Name {get; set;} + public string Author {get; set;} + public string Country {get; set;} + public string Link {get; set;} + public string Language {get; set;} + public long Pages {get; set;} + public long Year {get; set;} + public CategoryEnum Category { get; set; } + public string ImageLink { get; set; } + public long LendTime {get; set;} + public LendTypeEnum LendType {get; set;} + } + } \ No newline at end of file diff --git a/Models/ItemModel.cs b/Models/ItemModel.cs index 159b53b..b4ef5ed 100644 --- a/Models/ItemModel.cs +++ b/Models/ItemModel.cs @@ -59,8 +59,6 @@ namespace BuecherwurmAPI.Models while (dataReader.Read()) { - var returned = (long) dataReader["Returned"] == 1; - items.Add(new Item { ItemId = (long) dataReader["ItemId"], diff --git a/Models/KatalogModel.cs b/Models/KatalogModel.cs index e1dd357..64f2347 100644 --- a/Models/KatalogModel.cs +++ b/Models/KatalogModel.cs @@ -6,11 +6,15 @@ using Microsoft.VisualBasic.CompilerServices; namespace BuecherwurmAPI.Models { - internal class Katalog : IBookRepo + public interface ICatalogue + { + + } + internal class KatalogModel : ICatalogue { private SqliteConnection _dbConnection; - public Katalog() + public KatalogModel() { var connectionBuilder = new SqliteConnectionStringBuilder {DataSource = "LongWormMemory.db"}; _dbConnection = new SqliteConnection(connectionBuilder.ConnectionString); @@ -84,22 +88,21 @@ namespace BuecherwurmAPI.Models } } - public long AddBook (Book book) + public long AddBook (BookPost book) { using (var command = _dbConnection.CreateCommand()) { // funktioniert das so? //muss ProduktId übergeben werden? - command.CommandText = @"INSERT INTO Books (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType) VALUES (@Name, @Author, @Country, @Link, @Language, @Pages, @Year, @ProductId, @Category, @ImageLink, @LendTime, @LendType )"; + command.CommandText = @"INSERT INTO Books (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType) VALUES (@Name, @Author, @Country, @Link, @Language, @Pages, @Year, NULL, @Category, @ImageLink, @LendTime, @LendType )"; command.Parameters.Add(new SqliteParameter("@Name", book.Name)); command.Parameters.Add(new SqliteParameter("@Author", book.Author)); - command.Parameters.Add(new SqliteParameter("@Contry", book.Country)); + command.Parameters.Add(new SqliteParameter("@Country", book.Country)); command.Parameters.Add(new SqliteParameter("@Link", book.Link)); command.Parameters.Add(new SqliteParameter("@Language", book.Language)); command.Parameters.Add(new SqliteParameter("@Pages", book.Pages)); command.Parameters.Add(new SqliteParameter("@Year", book.Year)); - command.Parameters.Add(new SqliteParameter("@ProductId", book.ProductId)); command.Parameters.Add(new SqliteParameter("@Category", book.Category)); command.Parameters.Add(new SqliteParameter("@ImageLink", book.ImageLink)); command.Parameters.Add(new SqliteParameter("@LendTime", book.LendTime)); @@ -122,17 +125,16 @@ namespace BuecherwurmAPI.Models using (var command = _dbConnection.CreateCommand()) { // funktioniert das so? - command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = id; - command.CommandText = @"INSERT INTO Books (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType) VALUES (@Name, @Author, @Country, @Link, @Language, @Pages, @Year, @ProductId, @Category, @ImageLink, @LendTime, @LendType )"; + command.Parameters.Add(new SqliteParameter("@id", id)); + command.CommandText = @"UPDATE Books SET (Name, Author, Country, Link, Language, Pages, Year, Category, ImageLink, LendTime, LendType) = (@Name, @Author, @Country, @Link, @Language, @Pages, @Year, @Category, @ImageLink, @LendTime, @LendType ) WHERE ProductId = @id"; command.Parameters.Add(new SqliteParameter("@Name", book.Name)); command.Parameters.Add(new SqliteParameter("@Author", book.Author)); - command.Parameters.Add(new SqliteParameter("@Contry", book.Country)); + command.Parameters.Add(new SqliteParameter("@Country", book.Country)); command.Parameters.Add(new SqliteParameter("@Link", book.Link)); command.Parameters.Add(new SqliteParameter("@Language", book.Language)); command.Parameters.Add(new SqliteParameter("@Pages", book.Pages)); command.Parameters.Add(new SqliteParameter("@Year", book.Year)); - command.Parameters.Add(new SqliteParameter("@ProductId", book.ProductId)); command.Parameters.Add(new SqliteParameter("@Category", book.Category)); command.Parameters.Add(new SqliteParameter("@ImageLink", book.ImageLink)); command.Parameters.Add(new SqliteParameter("@LendTime", book.LendTime)); @@ -140,13 +142,7 @@ namespace BuecherwurmAPI.Models var success = command.ExecuteNonQuery(); - if (success == 1) - { - command.CommandText = @"SELECT last_insert_rowid()"; - return (long)command.ExecuteScalar(); - } - - return -1; + return id; } } diff --git a/Startup.cs b/Startup.cs index 1fc2f81..e8d9d83 100644 --- a/Startup.cs +++ b/Startup.cs @@ -34,6 +34,7 @@ namespace BuecherwurmAPI // That allows to swap the implementation easily. services.AddScoped(); services.AddScoped(); + services.AddScoped(); services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); }