From 80e8ff165c9beae935998c1f93c13f486b2a7847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=B5=D1=80?= =?UTF-8?q?=D0=B3=D1=83=D0=BD=D0=BE=D0=B2?= Date: Fri, 12 May 2023 12:08:11 +0400 Subject: [PATCH] add contracts, business logic & data models --- BookShop/BookShop.sln | 18 ++- .../BookShopBusinessLogic.csproj | 9 ++ .../BusinessLogics/AuthorLogic.cs | 116 ++++++++++++++++ .../BusinessLogics/BookLogic.cs | 129 ++++++++++++++++++ .../BusinessLogics/ClientLogic.cs | 119 ++++++++++++++++ .../BusinessLogics/GenreLogic.cs | 111 +++++++++++++++ .../BusinessLogics/OrderLogic.cs | 102 ++++++++++++++ .../BindingModels/AuthorBindingModel.cs | 15 ++ .../BindingModels/BookBindingModel.cs | 28 ++++ .../BindingModels/ClientBindingModel.cs | 18 +++ .../BindingModels/GenreBindingModel.cs | 11 ++ .../BindingModels/OrderBindingModel.cs | 23 ++++ .../BookShopContracts.csproj | 9 ++ .../BusinessLogicsContracts/IAuthorLogic.cs | 19 +++ .../BusinessLogicsContracts/IBookLogic.cs | 23 ++++ .../BusinessLogicsContracts/IClientLogic.cs | 19 +++ .../BusinessLogicsContracts/IGenreLogic.cs | 19 +++ .../BusinessLogicsContracts/IOrderLogic.cs | 15 ++ .../SearchModels/AuthorSearchModel.cs | 11 ++ .../SearchModels/BookSearchModel.cs | 9 ++ .../SearchModels/ClientSearchModel.cs | 15 ++ .../SearchModels/GenreSearchModel.cs | 9 ++ .../SearchModels/OrderSearchModel.cs | 11 ++ .../StoragesContracts/IAuthorStorage.cs | 21 +++ .../StoragesContracts/IBookStorage.cs | 25 ++++ .../StoragesContracts/IClientStorage.cs | 21 +++ .../StoragesContracts/IGenreStorage.cs | 21 +++ .../StoragesContracts/IOrderStorage.cs | 17 +++ .../ViewModels/AuthorViewModel.cs | 19 +++ .../ViewModels/BookViewModel.cs | 24 ++++ .../ViewModels/ClientViewModel.cs | 23 ++++ .../ViewModels/GenreViewModel.cs | 13 ++ .../ViewModels/OrderViewModel.cs | 29 ++++ .../BookShopDataModels.csproj | 9 ++ BookShop/BookShopDataModels/IId.cs | 7 + .../BookShopDataModels/Models/IAuthorModel.cs | 11 ++ .../BookShopDataModels/Models/IBookModel.cs | 15 ++ .../BookShopDataModels/Models/IClientModel.cs | 13 ++ .../BookShopDataModels/Models/IGenreModel.cs | 7 + .../BookShopDataModels/Models/IOrderModel.cs | 15 ++ .../BookShopView.csproj} | 0 .../Form1.Designer.cs | 2 +- BookShop/{BookShop => BookShopView}/Form1.cs | 2 +- .../{BookShop => BookShopView}/Form1.resx | 0 .../{BookShop => BookShopView}/Program.cs | 2 +- 45 files changed, 1145 insertions(+), 9 deletions(-) create mode 100644 BookShop/BookShopBusinessLogic/BookShopBusinessLogic.csproj create mode 100644 BookShop/BookShopBusinessLogic/BusinessLogics/AuthorLogic.cs create mode 100644 BookShop/BookShopBusinessLogic/BusinessLogics/BookLogic.cs create mode 100644 BookShop/BookShopBusinessLogic/BusinessLogics/ClientLogic.cs create mode 100644 BookShop/BookShopBusinessLogic/BusinessLogics/GenreLogic.cs create mode 100644 BookShop/BookShopBusinessLogic/BusinessLogics/OrderLogic.cs create mode 100644 BookShop/BookShopContracts/BindingModels/AuthorBindingModel.cs create mode 100644 BookShop/BookShopContracts/BindingModels/BookBindingModel.cs create mode 100644 BookShop/BookShopContracts/BindingModels/ClientBindingModel.cs create mode 100644 BookShop/BookShopContracts/BindingModels/GenreBindingModel.cs create mode 100644 BookShop/BookShopContracts/BindingModels/OrderBindingModel.cs create mode 100644 BookShop/BookShopContracts/BookShopContracts.csproj create mode 100644 BookShop/BookShopContracts/BusinessLogicsContracts/IAuthorLogic.cs create mode 100644 BookShop/BookShopContracts/BusinessLogicsContracts/IBookLogic.cs create mode 100644 BookShop/BookShopContracts/BusinessLogicsContracts/IClientLogic.cs create mode 100644 BookShop/BookShopContracts/BusinessLogicsContracts/IGenreLogic.cs create mode 100644 BookShop/BookShopContracts/BusinessLogicsContracts/IOrderLogic.cs create mode 100644 BookShop/BookShopContracts/SearchModels/AuthorSearchModel.cs create mode 100644 BookShop/BookShopContracts/SearchModels/BookSearchModel.cs create mode 100644 BookShop/BookShopContracts/SearchModels/ClientSearchModel.cs create mode 100644 BookShop/BookShopContracts/SearchModels/GenreSearchModel.cs create mode 100644 BookShop/BookShopContracts/SearchModels/OrderSearchModel.cs create mode 100644 BookShop/BookShopContracts/StoragesContracts/IAuthorStorage.cs create mode 100644 BookShop/BookShopContracts/StoragesContracts/IBookStorage.cs create mode 100644 BookShop/BookShopContracts/StoragesContracts/IClientStorage.cs create mode 100644 BookShop/BookShopContracts/StoragesContracts/IGenreStorage.cs create mode 100644 BookShop/BookShopContracts/StoragesContracts/IOrderStorage.cs create mode 100644 BookShop/BookShopContracts/ViewModels/AuthorViewModel.cs create mode 100644 BookShop/BookShopContracts/ViewModels/BookViewModel.cs create mode 100644 BookShop/BookShopContracts/ViewModels/ClientViewModel.cs create mode 100644 BookShop/BookShopContracts/ViewModels/GenreViewModel.cs create mode 100644 BookShop/BookShopContracts/ViewModels/OrderViewModel.cs create mode 100644 BookShop/BookShopDataModels/BookShopDataModels.csproj create mode 100644 BookShop/BookShopDataModels/IId.cs create mode 100644 BookShop/BookShopDataModels/Models/IAuthorModel.cs create mode 100644 BookShop/BookShopDataModels/Models/IBookModel.cs create mode 100644 BookShop/BookShopDataModels/Models/IClientModel.cs create mode 100644 BookShop/BookShopDataModels/Models/IGenreModel.cs create mode 100644 BookShop/BookShopDataModels/Models/IOrderModel.cs rename BookShop/{BookShop/BookShop.csproj => BookShopView/BookShopView.csproj} (100%) rename BookShop/{BookShop => BookShopView}/Form1.Designer.cs (97%) rename BookShop/{BookShop => BookShopView}/Form1.cs (79%) rename BookShop/{BookShop => BookShopView}/Form1.resx (100%) rename BookShop/{BookShop => BookShopView}/Program.cs (94%) diff --git a/BookShop/BookShop.sln b/BookShop/BookShop.sln index aa65932..cbefac8 100644 --- a/BookShop/BookShop.sln +++ b/BookShop/BookShop.sln @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.5.33530.505 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookShop", "BookShop\BookShop.csproj", "{946EC661-9CF9-43DA-9C97-A2CE481406D2}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookShopView", "BookShopView\BookShopView.csproj", "{1455C2BC-5C22-4B93-8954-ACC01353BD24}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookShopDataModels", "BookShopDataModels\BookShopDataModels.csproj", "{032BDFC0-6AAF-4A75-A9AE-B24C85A4679C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,15 +13,19 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {946EC661-9CF9-43DA-9C97-A2CE481406D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {946EC661-9CF9-43DA-9C97-A2CE481406D2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {946EC661-9CF9-43DA-9C97-A2CE481406D2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {946EC661-9CF9-43DA-9C97-A2CE481406D2}.Release|Any CPU.Build.0 = Release|Any CPU + {1455C2BC-5C22-4B93-8954-ACC01353BD24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1455C2BC-5C22-4B93-8954-ACC01353BD24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1455C2BC-5C22-4B93-8954-ACC01353BD24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1455C2BC-5C22-4B93-8954-ACC01353BD24}.Release|Any CPU.Build.0 = Release|Any CPU + {032BDFC0-6AAF-4A75-A9AE-B24C85A4679C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {032BDFC0-6AAF-4A75-A9AE-B24C85A4679C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {032BDFC0-6AAF-4A75-A9AE-B24C85A4679C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {032BDFC0-6AAF-4A75-A9AE-B24C85A4679C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F2A3B3D2-EC41-4B24-B6F1-95D5692C7561} + SolutionGuid = {CC21F821-D99C-4781-AD62-0FA7B3BA0F82} EndGlobalSection EndGlobal diff --git a/BookShop/BookShopBusinessLogic/BookShopBusinessLogic.csproj b/BookShop/BookShopBusinessLogic/BookShopBusinessLogic.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/BookShop/BookShopBusinessLogic/BookShopBusinessLogic.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/BookShop/BookShopBusinessLogic/BusinessLogics/AuthorLogic.cs b/BookShop/BookShopBusinessLogic/BusinessLogics/AuthorLogic.cs new file mode 100644 index 0000000..6e90f84 --- /dev/null +++ b/BookShop/BookShopBusinessLogic/BusinessLogics/AuthorLogic.cs @@ -0,0 +1,116 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.BusinessLogicsContracts; +using BookShopContracts.SearchModels; +using BookShopContracts.StoragesContracts; +using BookShopContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace BookShopBusinessLogic.BusinessLogics +{ + public class AuthorLogic : IAuthorLogic + { + private readonly ILogger _logger; + + private readonly IAuthorStorage _authorStorage; + + public AuthorLogic(ILogger logger, IAuthorStorage authorStorage) + { + _logger = logger; + _authorStorage = authorStorage; + } + + public bool Create(AuthorBindingModel model) + { + CheckModel(model); + if (_authorStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Delete(AuthorBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id: {Id}", model.Id); + if (_authorStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + public AuthorViewModel? ReadElement(AuthorSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. AuthorSurname: {AuthorSurname}. AuthorName: {AuthorName}. Id: {Id}.", model.AuthorSurname, model.AuthorName, model.Id); + var element = _authorStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id: {Id}", element.Id); + return element; + } + + public List? ReadList(AuthorSearchModel? model) + { + _logger.LogInformation("ReadList. AuthorSurname: {AuthorSurname}. AuthorName: {AuthorName}. Id: {Id}.", model?.AuthorSurname, model?.AuthorName, model?.Id); + var list = model == null ? _authorStorage.GetFullList() : _authorStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + return list; + } + + public bool Update(AuthorBindingModel model) + { + CheckModel(model); + if (_authorStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + private void CheckModel(AuthorBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.AuthorSurname)) + { + throw new ArgumentNullException("Нет фамилии клиента", nameof(model.AuthorSurname)); + } + if (string.IsNullOrEmpty(model.AuthorName)) + { + throw new ArgumentNullException("Нет имени клиента", nameof(model.AuthorName)); + } + _logger.LogInformation("Author. AuthorSurname: {AuthorSurname}. AuthorName: {AuthorName}. AuthorPatronymic: {AuthorPatronymic}. Id: {Id}.", model.AuthorSurname, model.AuthorName, model.AuthorPatronymic, model.Id); + var element = _authorStorage.GetElement(new AuthorSearchModel + { + AuthorSurname = model.AuthorSurname, + AuthorName = model.AuthorName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Автор с таким ФИО уже есть"); + } + } + } +} diff --git a/BookShop/BookShopBusinessLogic/BusinessLogics/BookLogic.cs b/BookShop/BookShopBusinessLogic/BusinessLogics/BookLogic.cs new file mode 100644 index 0000000..cfa2ec9 --- /dev/null +++ b/BookShop/BookShopBusinessLogic/BusinessLogics/BookLogic.cs @@ -0,0 +1,129 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.BusinessLogicsContracts; +using BookShopContracts.SearchModels; +using BookShopContracts.StoragesContracts; +using BookShopContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace BookShopBusinessLogic.BusinessLogics +{ + public class BookLogic : IBookLogic + { + private readonly ILogger _logger; + + private readonly IBookStorage _bookStorage; + + public BookLogic(ILogger logger, IBookStorage bookStorage) + { + _logger = logger; + _bookStorage = bookStorage; + } + + public bool Create(BookBindingModel model) + { + CheckModel(model); + if (_bookStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Delete(BookBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id: {Id}", model.Id); + if (_bookStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + public BookViewModel? ReadElement(BookSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. BookName: {BookName}. Id: {Id}.", model.BookName, model.Id); + var element = _bookStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id: {Id}", element.Id); + return element; + } + + public List? ReadList(BookSearchModel? model) + { + _logger.LogInformation("ReadList. BookName: {BookName}. Id: {Id}.", model?.BookName, model?.Id); + var list = model == null ? _bookStorage.GetFullList() : _bookStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + return list; + } + + public string TestInsertList(int num) + { + throw new NotImplementedException(); + } + + public string TestReadList(int num) + { + return _bookStorage.TestReadList(num); + } + + public bool Update(BookBindingModel model) + { + CheckModel(model); + if (_bookStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + private void CheckModel(BookBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.BookName)) + { + throw new ArgumentNullException("Нет названия книги", nameof(model.BookName)); + } + if (model.Count < 0) + { + throw new ArgumentNullException("Количество не может быть меньше 0", nameof(model.BookName)); + } + if (model.Cost <= 0) + { + throw new ArgumentNullException("Стоимость не может быть меньше 0", nameof(model.BookName)); + } + _logger.LogInformation("Book. BookName: {BookName}. Cost: {Cost}. Id: {Id}.", model.BookName, model.Cost, model.Id); + var element = _bookStorage.GetElement(new BookSearchModel + { + BookName = model.BookName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Книга с таким названием уже есть"); + } + } + } +} diff --git a/BookShop/BookShopBusinessLogic/BusinessLogics/ClientLogic.cs b/BookShop/BookShopBusinessLogic/BusinessLogics/ClientLogic.cs new file mode 100644 index 0000000..aa17753 --- /dev/null +++ b/BookShop/BookShopBusinessLogic/BusinessLogics/ClientLogic.cs @@ -0,0 +1,119 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.BusinessLogicsContracts; +using BookShopContracts.SearchModels; +using BookShopContracts.StoragesContracts; +using BookShopContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace BookShopBusinessLogic.BusinessLogics +{ + public class ClientLogic : IClientLogic + { + private readonly ILogger _logger; + + private readonly IClientStorage _clientStorage; + + public ClientLogic(ILogger logger, IClientStorage clientStorage) + { + _logger = logger; + _clientStorage = clientStorage; + } + + public bool Create(ClientBindingModel model) + { + CheckModel(model); + if (_clientStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Delete(ClientBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id: {Id}", model.Id); + if (_clientStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + public ClientViewModel? ReadElement(ClientSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ClientSurname: {ClientSurname}. ClientName: {ClientName}. ClientPatronymic: {ClientPatronymic}. Email: {Email}. Id: {Id}.", model.ClientSurname, model.ClientName, model.ClientPatronymic, model.Email, model.Id); + var element = _clientStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id: {Id}", element.Id); + return element; + } + + public List? ReadList(ClientSearchModel? model) + { + _logger.LogInformation("ReadList. ClientSurname: {ClientSurname}. ClientName: {ClientName}. ClientPatronymic: {ClientPatronymic}. Email: {Email}. Id: {Id}.", model?.ClientSurname, model?.ClientName, model?.ClientPatronymic, model?.Email, model?.Id); + var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + return list; + } + + public bool Update(ClientBindingModel model) + { + CheckModel(model); + if (_clientStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + private void CheckModel(ClientBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ClientSurname)) + { + throw new ArgumentNullException("Нет фамилии клиента", nameof(model.ClientSurname)); + } + if (string.IsNullOrEmpty(model.ClientName)) + { + throw new ArgumentNullException("Нет имени клиента", nameof(model.ClientName)); + } + if (string.IsNullOrEmpty(model.Email)) + { + throw new ArgumentNullException("Нет почты клиента", nameof(model.Email)); + } + _logger.LogInformation("Client. ClientSurname: {ClientSurname}. ClientName: {ClientName}. ClientPatronymic: {ClientPatronymic}. Email: {Email}. Id: {Id}.", model.ClientSurname, model.ClientName, model.ClientPatronymic, model.Email, model.Id); + var element = _clientStorage.GetElement(new ClientSearchModel + { + Email = model.Email + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Клиент с такой почтой уже есть"); + } + } + } +} diff --git a/BookShop/BookShopBusinessLogic/BusinessLogics/GenreLogic.cs b/BookShop/BookShopBusinessLogic/BusinessLogics/GenreLogic.cs new file mode 100644 index 0000000..2fa7d78 --- /dev/null +++ b/BookShop/BookShopBusinessLogic/BusinessLogics/GenreLogic.cs @@ -0,0 +1,111 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.BusinessLogicsContracts; +using BookShopContracts.SearchModels; +using BookShopContracts.StoragesContracts; +using BookShopContracts.ViewModels; +using BookShopDataModels.Models; +using Microsoft.Extensions.Logging; + +namespace BookShopBusinessLogic.BusinessLogics +{ + public class GenreLogic : IGenreLogic + { + private readonly ILogger _logger; + + private readonly IGenreStorage _genreStorage; + public GenreLogic(ILogger logger, IGenreStorage genreStorage) + { + _logger = logger; + _genreStorage = genreStorage; + } + + public bool Create(GenreBindingModel model) + { + CheckModel(model); + if (_genreStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Delete(GenreBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id: {Id}", model.Id); + if (_genreStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + public GenreViewModel? ReadElement(GenreSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. GenreName: {GenreName}. Id: {Id}.", model.GenreName, model.Id); + var element = _genreStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id: {Id}", element.Id); + return element; + } + + public List? ReadList(GenreSearchModel? model) + { + _logger.LogInformation("ReadList. GenreName: {GenreName}. Id: {Id}.", model?.GenreName, model?.Id); + var list = model == null ? _genreStorage.GetFullList() : _genreStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + return list; + } + + public bool Update(GenreBindingModel model) + { + CheckModel(model); + if (_genreStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + + private void CheckModel(GenreBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.GenreName)) + { + throw new ArgumentNullException("Нет названия жанра", nameof(model.GenreName)); + } + _logger.LogInformation("Genre. GenreName: {GenreName}. Id: {Id}.", model.GenreName, model.Id); + var element = _genreStorage.GetElement(new GenreSearchModel + { + GenreName = model.GenreName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Такой жанр уже есть"); + } + } + } +} diff --git a/BookShop/BookShopBusinessLogic/BusinessLogics/OrderLogic.cs b/BookShop/BookShopBusinessLogic/BusinessLogics/OrderLogic.cs new file mode 100644 index 0000000..b3c3c20 --- /dev/null +++ b/BookShop/BookShopBusinessLogic/BusinessLogics/OrderLogic.cs @@ -0,0 +1,102 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.BusinessLogicsContracts; +using BookShopContracts.SearchModels; +using BookShopContracts.StoragesContracts; +using BookShopContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace BookShopBusinessLogic.BusinessLogics +{ + public class OrderLogic : IOrderLogic + { + private readonly ILogger _logger; + + private readonly IOrderStorage _orderStorage; + + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + + public bool Create(OrderBindingModel model) + { + CheckModel(model); + + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + + return true; + } + + public List? ReadList(OrderSearchModel? model) + { + _logger.LogInformation("Order. OrderId:{Id}", model?.Id); + + var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + private void CheckModel(OrderBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + + if (model.BookId < 0) + { + throw new ArgumentNullException("Некорректный идентификатор книги", nameof(model.BookId)); + } + + if (model.Count <= 0) + { + throw new ArgumentNullException("Количество книг в заказе должно быть больше 0", nameof(model.Count)); + } + if (model.Sum <= 0) + { + throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum)); + } + + _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. Id: { BookId}", model.Id, model.Sum, model.BookId); + } + + public OrderViewModel? ReadElement(OrderSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. Id:{ Id}", model.Id); + + var element = _orderStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + + return null; + } + + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + + return element; + } + } +} diff --git a/BookShop/BookShopContracts/BindingModels/AuthorBindingModel.cs b/BookShop/BookShopContracts/BindingModels/AuthorBindingModel.cs new file mode 100644 index 0000000..3852329 --- /dev/null +++ b/BookShop/BookShopContracts/BindingModels/AuthorBindingModel.cs @@ -0,0 +1,15 @@ +using BookShopDataModels.Models; + +namespace BookShopContracts.BindingModels +{ + public class AuthorBindingModel : IAuthorModel + { + public int Id { get; set; } + + public string AuthorSurname { get; set; } = string.Empty; + + public string AuthorName { get; set; } = string.Empty; + + public string AuthorPatronymic { get; set; } = string.Empty; + } +} diff --git a/BookShop/BookShopContracts/BindingModels/BookBindingModel.cs b/BookShop/BookShopContracts/BindingModels/BookBindingModel.cs new file mode 100644 index 0000000..46ac549 --- /dev/null +++ b/BookShop/BookShopContracts/BindingModels/BookBindingModel.cs @@ -0,0 +1,28 @@ +using BookShopDataModels.Models; +using System.ComponentModel; + +namespace BookShopContracts.BindingModels +{ + public class BookBindingModel : IBookModel + { + public int Id { get; set; } + [DisplayName("Название")] + + public string BookName { get; set; } = string.Empty; + [DisplayName("Стоимость")] + + public double Cost { get; set; } + [DisplayName("Количество")] + + public int Count { get; set; } + [DisplayName("Жанр")] + + public int GenreId { get; set; } + + public Dictionary BookAuthors + { + get; + set; + } = new(); + } +} diff --git a/BookShop/BookShopContracts/BindingModels/ClientBindingModel.cs b/BookShop/BookShopContracts/BindingModels/ClientBindingModel.cs new file mode 100644 index 0000000..0511f11 --- /dev/null +++ b/BookShop/BookShopContracts/BindingModels/ClientBindingModel.cs @@ -0,0 +1,18 @@ +using BookShopDataModels.Models; + +namespace BookShopContracts.BindingModels +{ + public class ClientBindingModel : IClientModel + { + public int Id { get; set; } + + public string ClientSurname { get; set; } = string.Empty; + + public string ClientName { get; set; } = string.Empty; + + public string ClientPatronymic { get; set; } = string.Empty; + + public string Email { get; set; } = string.Empty; + + } +} diff --git a/BookShop/BookShopContracts/BindingModels/GenreBindingModel.cs b/BookShop/BookShopContracts/BindingModels/GenreBindingModel.cs new file mode 100644 index 0000000..cfbe329 --- /dev/null +++ b/BookShop/BookShopContracts/BindingModels/GenreBindingModel.cs @@ -0,0 +1,11 @@ +using BookShopDataModels.Models; + +namespace BookShopContracts.BindingModels +{ + public class GenreBindingModel : IGenreModel + { + public int Id { get; set; } + + public string GenreName { get; set; } = string.Empty; + } +} diff --git a/BookShop/BookShopContracts/BindingModels/OrderBindingModel.cs b/BookShop/BookShopContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..781cafc --- /dev/null +++ b/BookShop/BookShopContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,23 @@ +using BookShopDataModels.Models; + +namespace BookShopContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + + public int BookId { get; set; } + + public string BookName { get; set; } = string.Empty; + + public int ClientId { get; set; } + + public string ClientName { get; set; } = string.Empty; + + public int Count { get; set; } + + public double Sum { get; set; } + + public DateTime DateCreate { get; set; } = DateTime.Now; + } +} diff --git a/BookShop/BookShopContracts/BookShopContracts.csproj b/BookShop/BookShopContracts/BookShopContracts.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/BookShop/BookShopContracts/BookShopContracts.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/BookShop/BookShopContracts/BusinessLogicsContracts/IAuthorLogic.cs b/BookShop/BookShopContracts/BusinessLogicsContracts/IAuthorLogic.cs new file mode 100644 index 0000000..954b9e9 --- /dev/null +++ b/BookShop/BookShopContracts/BusinessLogicsContracts/IAuthorLogic.cs @@ -0,0 +1,19 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.SearchModels; +using BookShopContracts.ViewModels; + +namespace BookShopContracts.BusinessLogicsContracts +{ + public interface IAuthorLogic + { + List? ReadList(AuthorSearchModel? model); + + AuthorViewModel? ReadElement(AuthorSearchModel model); + + bool Create(AuthorBindingModel model); + + bool Update(AuthorBindingModel model); + + bool Delete(AuthorBindingModel model); + } +} diff --git a/BookShop/BookShopContracts/BusinessLogicsContracts/IBookLogic.cs b/BookShop/BookShopContracts/BusinessLogicsContracts/IBookLogic.cs new file mode 100644 index 0000000..3122f0a --- /dev/null +++ b/BookShop/BookShopContracts/BusinessLogicsContracts/IBookLogic.cs @@ -0,0 +1,23 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.SearchModels; +using BookShopContracts.ViewModels; + +namespace BookShopContracts.BusinessLogicsContracts +{ + public interface IBookLogic + { + List? ReadList(BookSearchModel? model); + + BookViewModel? ReadElement(BookSearchModel model); + + bool Create(BookBindingModel model); + + bool Update(BookBindingModel model); + + bool Delete(BookBindingModel model); + + string TestInsertList(int num); + + string TestReadList(int num); + } +} diff --git a/BookShop/BookShopContracts/BusinessLogicsContracts/IClientLogic.cs b/BookShop/BookShopContracts/BusinessLogicsContracts/IClientLogic.cs new file mode 100644 index 0000000..79f00f8 --- /dev/null +++ b/BookShop/BookShopContracts/BusinessLogicsContracts/IClientLogic.cs @@ -0,0 +1,19 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.SearchModels; +using BookShopContracts.ViewModels; + +namespace BookShopContracts.BusinessLogicsContracts +{ + public interface IClientLogic + { + List? ReadList(ClientSearchModel? model); + + ClientViewModel? ReadElement(ClientSearchModel model); + + bool Create(ClientBindingModel model); + + bool Update(ClientBindingModel model); + + bool Delete(ClientBindingModel model); + } +} diff --git a/BookShop/BookShopContracts/BusinessLogicsContracts/IGenreLogic.cs b/BookShop/BookShopContracts/BusinessLogicsContracts/IGenreLogic.cs new file mode 100644 index 0000000..d4e65ee --- /dev/null +++ b/BookShop/BookShopContracts/BusinessLogicsContracts/IGenreLogic.cs @@ -0,0 +1,19 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.SearchModels; +using BookShopContracts.ViewModels; + +namespace BookShopContracts.BusinessLogicsContracts +{ + public interface IGenreLogic + { + List? ReadList(GenreSearchModel? model); + + GenreViewModel? ReadElement(GenreSearchModel model); + + bool Create(GenreBindingModel model); + + bool Update(GenreBindingModel model); + + bool Delete(GenreBindingModel model); + } +} diff --git a/BookShop/BookShopContracts/BusinessLogicsContracts/IOrderLogic.cs b/BookShop/BookShopContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..e3c01e3 --- /dev/null +++ b/BookShop/BookShopContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,15 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.SearchModels; +using BookShopContracts.ViewModels; + +namespace BookShopContracts.BusinessLogicsContracts +{ + public interface IOrderLogic + { + List? ReadList(OrderSearchModel? model); + + OrderViewModel? ReadElement(OrderSearchModel model); + + bool Create(OrderBindingModel model); + } +} diff --git a/BookShop/BookShopContracts/SearchModels/AuthorSearchModel.cs b/BookShop/BookShopContracts/SearchModels/AuthorSearchModel.cs new file mode 100644 index 0000000..2f68560 --- /dev/null +++ b/BookShop/BookShopContracts/SearchModels/AuthorSearchModel.cs @@ -0,0 +1,11 @@ +namespace BookShopContracts.SearchModels +{ + public class AuthorSearchModel + { + public int? Id { get; set; } + + public string? AuthorSurname { get; set; } + + public string? AuthorName { get; set; } + } +} diff --git a/BookShop/BookShopContracts/SearchModels/BookSearchModel.cs b/BookShop/BookShopContracts/SearchModels/BookSearchModel.cs new file mode 100644 index 0000000..cb59529 --- /dev/null +++ b/BookShop/BookShopContracts/SearchModels/BookSearchModel.cs @@ -0,0 +1,9 @@ +namespace BookShopContracts.SearchModels +{ + public class BookSearchModel + { + public int? Id { get; set; } + + public string? BookName { get; set; } + } +} diff --git a/BookShop/BookShopContracts/SearchModels/ClientSearchModel.cs b/BookShop/BookShopContracts/SearchModels/ClientSearchModel.cs new file mode 100644 index 0000000..290cb22 --- /dev/null +++ b/BookShop/BookShopContracts/SearchModels/ClientSearchModel.cs @@ -0,0 +1,15 @@ +namespace BookShopContracts.SearchModels +{ + public class ClientSearchModel + { + public int? Id { get; set; } + + public string? ClientSurname { get; set; } + + public string? ClientName { get; set; } + + public string? ClientPatronymic { get; set; } + + public string? Email { get; set; } + } +} diff --git a/BookShop/BookShopContracts/SearchModels/GenreSearchModel.cs b/BookShop/BookShopContracts/SearchModels/GenreSearchModel.cs new file mode 100644 index 0000000..8fa1747 --- /dev/null +++ b/BookShop/BookShopContracts/SearchModels/GenreSearchModel.cs @@ -0,0 +1,9 @@ +namespace BookShopContracts.SearchModels +{ + public class GenreSearchModel + { + public int? Id { get; set; } + + public string? GenreName { get; set; } + } +} diff --git a/BookShop/BookShopContracts/SearchModels/OrderSearchModel.cs b/BookShop/BookShopContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..15e39c8 --- /dev/null +++ b/BookShop/BookShopContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,11 @@ +namespace BookShopContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + + public int? ClientId { get; set; } + + public DateTime? DateCreate { get; set; } + } +} diff --git a/BookShop/BookShopContracts/StoragesContracts/IAuthorStorage.cs b/BookShop/BookShopContracts/StoragesContracts/IAuthorStorage.cs new file mode 100644 index 0000000..35086b7 --- /dev/null +++ b/BookShop/BookShopContracts/StoragesContracts/IAuthorStorage.cs @@ -0,0 +1,21 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.SearchModels; +using BookShopContracts.ViewModels; + +namespace BookShopContracts.StoragesContracts +{ + public interface IAuthorStorage + { + List GetFullList(); + + List GetFilteredList(AuthorSearchModel model); + + AuthorViewModel? GetElement(AuthorSearchModel model); + + AuthorViewModel? Insert(AuthorBindingModel model); + + AuthorViewModel? Update(AuthorBindingModel model); + + AuthorViewModel? Delete(AuthorBindingModel model); + } +} diff --git a/BookShop/BookShopContracts/StoragesContracts/IBookStorage.cs b/BookShop/BookShopContracts/StoragesContracts/IBookStorage.cs new file mode 100644 index 0000000..aba342f --- /dev/null +++ b/BookShop/BookShopContracts/StoragesContracts/IBookStorage.cs @@ -0,0 +1,25 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.SearchModels; +using BookShopContracts.ViewModels; + +namespace BookShopContracts.StoragesContracts +{ + public interface IBookStorage + { + List GetFullList(); + + List GetFilteredList(BookSearchModel model); + + BookViewModel? GetElement(BookSearchModel model); + + BookViewModel? Insert(BookBindingModel model); + + BookViewModel? Update(BookBindingModel model); + + BookViewModel? Delete(BookBindingModel model); + + string TestInsertList(int num); + + string TestReadList(int num); + } +} diff --git a/BookShop/BookShopContracts/StoragesContracts/IClientStorage.cs b/BookShop/BookShopContracts/StoragesContracts/IClientStorage.cs new file mode 100644 index 0000000..209ba24 --- /dev/null +++ b/BookShop/BookShopContracts/StoragesContracts/IClientStorage.cs @@ -0,0 +1,21 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.SearchModels; +using BookShopContracts.ViewModels; + +namespace BookShopContracts.StoragesContracts +{ + public interface IClientStorage + { + List GetFullList(); + + List GetFilteredList(ClientSearchModel model); + + ClientViewModel? GetElement(ClientSearchModel model); + + ClientViewModel? Insert(ClientBindingModel model); + + ClientViewModel? Update(ClientBindingModel model); + + ClientViewModel? Delete(ClientBindingModel model); + } +} diff --git a/BookShop/BookShopContracts/StoragesContracts/IGenreStorage.cs b/BookShop/BookShopContracts/StoragesContracts/IGenreStorage.cs new file mode 100644 index 0000000..93b6a2c --- /dev/null +++ b/BookShop/BookShopContracts/StoragesContracts/IGenreStorage.cs @@ -0,0 +1,21 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.SearchModels; +using BookShopContracts.ViewModels; + +namespace BookShopContracts.StoragesContracts +{ + public interface IGenreStorage + { + List GetFullList(); + + List GetFilteredList(GenreSearchModel model); + + GenreViewModel? GetElement(GenreSearchModel model); + + GenreViewModel? Insert(GenreBindingModel model); + + GenreViewModel? Update(GenreBindingModel model); + + GenreViewModel? Delete(GenreBindingModel model); + } +} diff --git a/BookShop/BookShopContracts/StoragesContracts/IOrderStorage.cs b/BookShop/BookShopContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..dfb05d5 --- /dev/null +++ b/BookShop/BookShopContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,17 @@ +using BookShopContracts.BindingModels; +using BookShopContracts.SearchModels; +using BookShopContracts.ViewModels; + +namespace BookShopContracts.StoragesContracts +{ + public interface IOrderStorage + { + List GetFullList(); + + List GetFilteredList(OrderSearchModel model); + + OrderViewModel? GetElement(OrderSearchModel model); + + OrderViewModel? Insert(OrderBindingModel model); + } +} diff --git a/BookShop/BookShopContracts/ViewModels/AuthorViewModel.cs b/BookShop/BookShopContracts/ViewModels/AuthorViewModel.cs new file mode 100644 index 0000000..831e81b --- /dev/null +++ b/BookShop/BookShopContracts/ViewModels/AuthorViewModel.cs @@ -0,0 +1,19 @@ +using BookShopDataModels.Models; +using System.ComponentModel; + +namespace BookShopContracts.ViewModels +{ + public class AuthorViewModel: IAuthorModel + { + public int Id { get; set; } + [DisplayName("Фамилия автора")] + + public string AuthorSurname { get; set; } = string.Empty; + [DisplayName("Имя автора")] + + public string AuthorName { get; set; } = string.Empty; + [DisplayName("Отчество автора")] + + public string AuthorPatronymic { get; set; } = string.Empty; + } +} diff --git a/BookShop/BookShopContracts/ViewModels/BookViewModel.cs b/BookShop/BookShopContracts/ViewModels/BookViewModel.cs new file mode 100644 index 0000000..18402c6 --- /dev/null +++ b/BookShop/BookShopContracts/ViewModels/BookViewModel.cs @@ -0,0 +1,24 @@ +using BookShopDataModels.Models; +using System.ComponentModel; + +namespace BookShopContracts.ViewModels +{ + public class BookViewModel: IBookModel + { + public int Id { get; set; } + [DisplayName("Название")] + + public string BookName { get; set; } = string.Empty; + [DisplayName("Стоимость")] + + public double Cost { get; set; } + + public int Count { get; set; } + + public int GenreId { get; set; } + + public string GenreName { get; set; } = string.Empty; + + public Dictionary BookAuthors { get; set; } = new(); + } +} diff --git a/BookShop/BookShopContracts/ViewModels/ClientViewModel.cs b/BookShop/BookShopContracts/ViewModels/ClientViewModel.cs new file mode 100644 index 0000000..3c27a74 --- /dev/null +++ b/BookShop/BookShopContracts/ViewModels/ClientViewModel.cs @@ -0,0 +1,23 @@ +using BookShopContracts.BusinessLogicsContracts; +using BookShopDataModels.Models; +using System.ComponentModel; + +namespace BookShopContracts.ViewModels +{ + public class ClientViewModel: IClientModel + { + public int Id { get; set; } + [DisplayName("Фамилия клиента")] + + public string ClientSurname { get; set; } = string.Empty; + [DisplayName("Имя клиента")] + + public string ClientName { get; set; } = string.Empty; + [DisplayName("Отчество клиента")] + + public string ClientPatronymic { get; set; } = string.Empty; + [DisplayName("Электронная почта клиента")] + + public string Email { get; set; } = string.Empty; + } +} diff --git a/BookShop/BookShopContracts/ViewModels/GenreViewModel.cs b/BookShop/BookShopContracts/ViewModels/GenreViewModel.cs new file mode 100644 index 0000000..575b225 --- /dev/null +++ b/BookShop/BookShopContracts/ViewModels/GenreViewModel.cs @@ -0,0 +1,13 @@ +using BookShopDataModels.Models; +using System.ComponentModel; + +namespace BookShopContracts.ViewModels +{ + public class GenreViewModel: IGenreModel + { + public int Id { get; set; } + [DisplayName("Жанр")] + + public string GenreName { get; set; } = string.Empty; + } +} diff --git a/BookShop/BookShopContracts/ViewModels/OrderViewModel.cs b/BookShop/BookShopContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..c521531 --- /dev/null +++ b/BookShop/BookShopContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,29 @@ +using BookShopDataModels.Models; +using System.ComponentModel; + +namespace BookShopContracts.ViewModels +{ + public class OrderViewModel: IOrderModel + { + public int Id { get; set; } + + public int BookId { get; set; } + [DisplayName("Название книги")] + + public string BookName { get; set; } = string.Empty; + + public int ClientId { get; set; } + [DisplayName("Фамилия клиента")] + + public string ClientSurname {get; set; } = string.Empty; + [DisplayName("Количество")] + + public int Count { get; set; } + [DisplayName("Сумма")] + + public double Sum { get; set; } + [DisplayName("Дата заказа")] + + public DateTime DateCreate { get; set; } = DateTime.Now; + } +} diff --git a/BookShop/BookShopDataModels/BookShopDataModels.csproj b/BookShop/BookShopDataModels/BookShopDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/BookShop/BookShopDataModels/BookShopDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/BookShop/BookShopDataModels/IId.cs b/BookShop/BookShopDataModels/IId.cs new file mode 100644 index 0000000..17dbe0d --- /dev/null +++ b/BookShop/BookShopDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace BookShopDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/BookShop/BookShopDataModels/Models/IAuthorModel.cs b/BookShop/BookShopDataModels/Models/IAuthorModel.cs new file mode 100644 index 0000000..19a6209 --- /dev/null +++ b/BookShop/BookShopDataModels/Models/IAuthorModel.cs @@ -0,0 +1,11 @@ +namespace BookShopDataModels.Models +{ + public interface IAuthorModel: IId + { + string AuthorSurname { get; } + + string AuthorName { get; } + + string AuthorPatronymic { get; } + } +} diff --git a/BookShop/BookShopDataModels/Models/IBookModel.cs b/BookShop/BookShopDataModels/Models/IBookModel.cs new file mode 100644 index 0000000..8936b28 --- /dev/null +++ b/BookShop/BookShopDataModels/Models/IBookModel.cs @@ -0,0 +1,15 @@ +namespace BookShopDataModels.Models +{ + public interface IBookModel: IId + { + string BookName { get; } + + double Cost { get; } + + int Count { get; } + + int GenreId { get; } + + Dictionary BookAuthors { get; } + } +} diff --git a/BookShop/BookShopDataModels/Models/IClientModel.cs b/BookShop/BookShopDataModels/Models/IClientModel.cs new file mode 100644 index 0000000..95cd1fa --- /dev/null +++ b/BookShop/BookShopDataModels/Models/IClientModel.cs @@ -0,0 +1,13 @@ +namespace BookShopDataModels.Models +{ + public interface IClientModel: IId + { + string ClientSurname { get; } + + string ClientName { get; } + + string ClientPatronymic { get; } + + string Email { get; } + } +} diff --git a/BookShop/BookShopDataModels/Models/IGenreModel.cs b/BookShop/BookShopDataModels/Models/IGenreModel.cs new file mode 100644 index 0000000..fba6efe --- /dev/null +++ b/BookShop/BookShopDataModels/Models/IGenreModel.cs @@ -0,0 +1,7 @@ +namespace BookShopDataModels.Models +{ + public interface IGenreModel : IId + { + string GenreName { get; } + } +} diff --git a/BookShop/BookShopDataModels/Models/IOrderModel.cs b/BookShop/BookShopDataModels/Models/IOrderModel.cs new file mode 100644 index 0000000..551950c --- /dev/null +++ b/BookShop/BookShopDataModels/Models/IOrderModel.cs @@ -0,0 +1,15 @@ +namespace BookShopDataModels.Models +{ + public interface IOrderModel: IId + { + int Count { get; } + + int BookId { get; } + + int ClientId { get; } + + double Sum { get; } + + DateTime DateCreate { get; } + } +} diff --git a/BookShop/BookShop/BookShop.csproj b/BookShop/BookShopView/BookShopView.csproj similarity index 100% rename from BookShop/BookShop/BookShop.csproj rename to BookShop/BookShopView/BookShopView.csproj diff --git a/BookShop/BookShop/Form1.Designer.cs b/BookShop/BookShopView/Form1.Designer.cs similarity index 97% rename from BookShop/BookShop/Form1.Designer.cs rename to BookShop/BookShopView/Form1.Designer.cs index 4fdd9f7..8fdf3cd 100644 --- a/BookShop/BookShop/Form1.Designer.cs +++ b/BookShop/BookShopView/Form1.Designer.cs @@ -1,4 +1,4 @@ -namespace BookShop +namespace BookShopView { partial class Form1 { diff --git a/BookShop/BookShop/Form1.cs b/BookShop/BookShopView/Form1.cs similarity index 79% rename from BookShop/BookShop/Form1.cs rename to BookShop/BookShopView/Form1.cs index b2c163f..8004282 100644 --- a/BookShop/BookShop/Form1.cs +++ b/BookShop/BookShopView/Form1.cs @@ -1,4 +1,4 @@ -namespace BookShop +namespace BookShopView { public partial class Form1 : Form { diff --git a/BookShop/BookShop/Form1.resx b/BookShop/BookShopView/Form1.resx similarity index 100% rename from BookShop/BookShop/Form1.resx rename to BookShop/BookShopView/Form1.resx diff --git a/BookShop/BookShop/Program.cs b/BookShop/BookShopView/Program.cs similarity index 94% rename from BookShop/BookShop/Program.cs rename to BookShop/BookShopView/Program.cs index faf2433..f60ba3b 100644 --- a/BookShop/BookShop/Program.cs +++ b/BookShop/BookShopView/Program.cs @@ -1,4 +1,4 @@ -namespace BookShop +namespace BookShopView { internal static class Program {