From 2892df921acbe0814c8834783535c632e3125be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=9C=D0=B0=D0=BB?= =?UTF-8?q?=D0=B0=D1=84=D0=B5=D0=B5=D0=B2?= Date: Sat, 18 May 2024 14:02:42 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BF=D1=83=D1=81=D1=82?= =?UTF-8?q?=D0=B8=D0=BB=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/BackUpSaveBinidngModel.cs | 13 ++++++++ .../BusinessLogicsContracts/IBackUpLogic.cs | 14 ++++++++ .../StoragesContracts/IBackUpInfo.cs | 15 +++++++++ .../Implements/BackUpInfo.cs | 32 +++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 JewelryStore/JewelryStoreContracts/BindingModels/BackUpSaveBinidngModel.cs create mode 100644 JewelryStore/JewelryStoreContracts/BusinessLogicsContracts/IBackUpLogic.cs create mode 100644 JewelryStore/JewelryStoreContracts/StoragesContracts/IBackUpInfo.cs create mode 100644 JewelryStore/JewelryStoreDatabaseImplement/Implements/BackUpInfo.cs diff --git a/JewelryStore/JewelryStoreContracts/BindingModels/BackUpSaveBinidngModel.cs b/JewelryStore/JewelryStoreContracts/BindingModels/BackUpSaveBinidngModel.cs new file mode 100644 index 0000000..c0de2f6 --- /dev/null +++ b/JewelryStore/JewelryStoreContracts/BindingModels/BackUpSaveBinidngModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JewelryStoreContracts.BindingModels +{ + public class BackUpSaveBinidngModel + { + public string FolderName { get; set; } = string.Empty; + } +} diff --git a/JewelryStore/JewelryStoreContracts/BusinessLogicsContracts/IBackUpLogic.cs b/JewelryStore/JewelryStoreContracts/BusinessLogicsContracts/IBackUpLogic.cs new file mode 100644 index 0000000..aee7af4 --- /dev/null +++ b/JewelryStore/JewelryStoreContracts/BusinessLogicsContracts/IBackUpLogic.cs @@ -0,0 +1,14 @@ +using JewelryStoreContracts.BindingModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JewelryStoreContracts.BusinessLogicsContracts +{ + public interface IBackUpLogic + { + void CreateBackUp(BackUpSaveBinidngModel model); + } +} diff --git a/JewelryStore/JewelryStoreContracts/StoragesContracts/IBackUpInfo.cs b/JewelryStore/JewelryStoreContracts/StoragesContracts/IBackUpInfo.cs new file mode 100644 index 0000000..cd78235 --- /dev/null +++ b/JewelryStore/JewelryStoreContracts/StoragesContracts/IBackUpInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JewelryStoreContracts.StoragesContracts +{ + public interface IBackUpInfo + { + List? GetList() where T : class, new(); + Type? GetTypeByModelInterface(string modelInterfaceName); + } + +} diff --git a/JewelryStore/JewelryStoreDatabaseImplement/Implements/BackUpInfo.cs b/JewelryStore/JewelryStoreDatabaseImplement/Implements/BackUpInfo.cs new file mode 100644 index 0000000..e027d50 --- /dev/null +++ b/JewelryStore/JewelryStoreDatabaseImplement/Implements/BackUpInfo.cs @@ -0,0 +1,32 @@ +using JewelryStoreContracts.StoragesContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JewelryStoreDatabaseImplement.Implements +{ + public class BackUpInfo : IBackUpInfo + { + public List? GetList() where T : class, new() + { + using var context = new JewelryStoreDatabase(); + return context.Set().ToList(); + } + public Type? GetTypeByModelInterface(string modelInterfaceName) + { + var assembly = typeof(BackUpInfo).Assembly; + var types = assembly.GetTypes(); + foreach (var type in types) + { + if (type.IsClass && + type.GetInterface(modelInterfaceName) != null) + { + return type; + } + } + return null; + } + } +}