diff --git a/Confectionery/ConfectioneryContracts/BindingModels/BackUpSaveBinidngModel.cs b/Confectionery/ConfectioneryContracts/BindingModels/BackUpSaveBinidngModel.cs new file mode 100644 index 0000000..d9c4f01 --- /dev/null +++ b/Confectionery/ConfectioneryContracts/BindingModels/BackUpSaveBinidngModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.BindingModels +{ + public class BackUpSaveBinidngModel + { + public string FolderName { get; set; } = string.Empty; + } +} diff --git a/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IBackUpLogic.cs b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IBackUpLogic.cs new file mode 100644 index 0000000..d037887 --- /dev/null +++ b/Confectionery/ConfectioneryContracts/BusinessLogicsContracts/IBackUpLogic.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ConfectioneryContracts.BindingModels; + +namespace ConfectioneryContracts.BusinessLogicsContracts +{ + public interface IBackUpLogic + { + void CreateBackUp(BackUpSaveBinidngModel model); + } +} diff --git a/Confectionery/ConfectioneryContracts/StoragesContracts/IBackUpInfo.cs b/Confectionery/ConfectioneryContracts/StoragesContracts/IBackUpInfo.cs new file mode 100644 index 0000000..3a66c37 --- /dev/null +++ b/Confectionery/ConfectioneryContracts/StoragesContracts/IBackUpInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryContracts.StoragesContracts +{ + public interface IBackUpInfo + { + List? GetList() where T : class, new(); + + Type? GetTypeByModelInterface(string modelInterfaceName); + } +} diff --git a/Confectionery/ConfectioneryDatabaseImplement/BackUpInfo.cs b/Confectionery/ConfectioneryDatabaseImplement/BackUpInfo.cs new file mode 100644 index 0000000..8285fba --- /dev/null +++ b/Confectionery/ConfectioneryDatabaseImplement/BackUpInfo.cs @@ -0,0 +1,32 @@ +using ConfectioneryContracts.StoragesContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryDatabaseImplement.Implements +{ + public class BackUpInfo : IBackUpInfo + { + public List? GetList() where T : class, new() + { + using var context = new ConfectioneryDatabase(); + 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; + } + } +}