diff --git a/ServiceStation/ServiceStation.sln b/ServiceStation/ServiceStation.sln index 97378dc..d6a2237 100644 --- a/ServiceStation/ServiceStation.sln +++ b/ServiceStation/ServiceStation.sln @@ -3,24 +3,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.6.33717.318 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationContracts", "ServiceStationContracts\ServiceStationContracts.csproj", "{3EDBD45F-CA76-4AD6-BE55-17FF18507EB1}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationDataModels", "ServiceStationDataModels\ServiceStationDataModels.csproj", "{431172B6-C074-45F3-8064-4D8D7F3F9FD2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStationsDataBaseImplement", "ServiceStationsDataBaseImplement\ServiceStationsDataBaseImplement.csproj", "{71AAE393-32B8-4E7C-8EC2-C0D98F5E3FCF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3EDBD45F-CA76-4AD6-BE55-17FF18507EB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3EDBD45F-CA76-4AD6-BE55-17FF18507EB1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3EDBD45F-CA76-4AD6-BE55-17FF18507EB1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3EDBD45F-CA76-4AD6-BE55-17FF18507EB1}.Release|Any CPU.Build.0 = Release|Any CPU {431172B6-C074-45F3-8064-4D8D7F3F9FD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {431172B6-C074-45F3-8064-4D8D7F3F9FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU {431172B6-C074-45F3-8064-4D8D7F3F9FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU {431172B6-C074-45F3-8064-4D8D7F3F9FD2}.Release|Any CPU.Build.0 = Release|Any CPU + {71AAE393-32B8-4E7C-8EC2-C0D98F5E3FCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {71AAE393-32B8-4E7C-8EC2-C0D98F5E3FCF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {71AAE393-32B8-4E7C-8EC2-C0D98F5E3FCF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {71AAE393-32B8-4E7C-8EC2-C0D98F5E3FCF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ServiceStation/ServiceStationContracts/ServiceStationContracts.csproj b/ServiceStation/ServiceStationContracts/ServiceStationContracts.csproj index cfadb03..5d5783f 100644 --- a/ServiceStation/ServiceStationContracts/ServiceStationContracts.csproj +++ b/ServiceStation/ServiceStationContracts/ServiceStationContracts.csproj @@ -6,4 +6,8 @@ enable + + + + diff --git a/ServiceStation/ServiceStationContracts/StorageContracts/ICategoryWorkStorage.cs b/ServiceStation/ServiceStationContracts/StorageContracts/ICategoryWorkStorage.cs new file mode 100644 index 0000000..b0118e3 --- /dev/null +++ b/ServiceStation/ServiceStationContracts/StorageContracts/ICategoryWorkStorage.cs @@ -0,0 +1,21 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceStationsContracts.StorageContracts +{ + public interface ICategoryWorkStorage + { + List GetFullList(); + List GetFilteredList(CategoryWorkSearchModel model); + CategoryWorkViewModel? GetElement(CategoryWorkSearchModel model); + CategoryWorkViewModel? Insert(CategoryWorkBindingModel model); + CategoryWorkViewModel? Update(CategoryWorkBindingModel model); + CategoryWorkViewModel? Delete(CategoryWorkBindingModel model); + } +} diff --git a/ServiceStation/ServiceStationContracts/StorageContracts/IClientStorage.cs b/ServiceStation/ServiceStationContracts/StorageContracts/IClientStorage.cs new file mode 100644 index 0000000..cc44b3a --- /dev/null +++ b/ServiceStation/ServiceStationContracts/StorageContracts/IClientStorage.cs @@ -0,0 +1,21 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceStationsContracts.StorageContracts +{ + 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/ServiceStation/ServiceStationContracts/StorageContracts/IClientWorkStorage.cs b/ServiceStation/ServiceStationContracts/StorageContracts/IClientWorkStorage.cs new file mode 100644 index 0000000..1b4811e --- /dev/null +++ b/ServiceStation/ServiceStationContracts/StorageContracts/IClientWorkStorage.cs @@ -0,0 +1,21 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceStationsContracts.StorageContracts +{ + public interface IClientWorkStorage + { + List GetFullList(); + List GetFilteredList(ClientWorkSearchModel model); + ClientWorkViewModel? GetElement(ClientWorkSearchModel model); + ClientWorkViewModel? Insert(ClientWorkBindingModel model); + ClientWorkViewModel? Update(ClientWorkBindingModel model); + ClientWorkViewModel? Delete(ClientWorkBindingModel model); + } +} diff --git a/ServiceStation/ServiceStationContracts/StorageContracts/IExecutorStorage.cs b/ServiceStation/ServiceStationContracts/StorageContracts/IExecutorStorage.cs new file mode 100644 index 0000000..8dabf9f --- /dev/null +++ b/ServiceStation/ServiceStationContracts/StorageContracts/IExecutorStorage.cs @@ -0,0 +1,21 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceStationsContracts.StorageContracts +{ + public interface IExecutorStorage + { + List GetFullList(); + List GetFilteredList(ExecutorSearchModel model); + ExecutorViewModel? GetElement(ExecutorSearchModel model); + ExecutorViewModel? Insert(ExecutorBindingModel model); + ExecutorViewModel? Update(ExecutorBindingModel model); + ExecutorViewModel? Delete(ExecutorBindingModel model); + } +} diff --git a/ServiceStation/ServiceStationContracts/StorageContracts/IReportStorage.cs b/ServiceStation/ServiceStationContracts/StorageContracts/IReportStorage.cs new file mode 100644 index 0000000..db5c3e2 --- /dev/null +++ b/ServiceStation/ServiceStationContracts/StorageContracts/IReportStorage.cs @@ -0,0 +1,21 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceStationsContracts.StorageContracts +{ + public interface IReportStorage + { + List GetFullList(); + List GetFilteredList(ReportSearchModel model); + ReportViewModel? GetElement(ReportSearchModel model); + ReportViewModel? Insert(ReportBindingModel model); + ReportViewModel? Update(ReportBindingModel model); + ReportViewModel? Delete(ReportBindingModel model); + } +} diff --git a/ServiceStation/ServiceStationContracts/StorageContracts/IWorkStorage.cs b/ServiceStation/ServiceStationContracts/StorageContracts/IWorkStorage.cs new file mode 100644 index 0000000..9abe5eb --- /dev/null +++ b/ServiceStation/ServiceStationContracts/StorageContracts/IWorkStorage.cs @@ -0,0 +1,21 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceStationsContracts.StorageContracts +{ + public interface IWorkStorage + { + List GetFullList(); + List GetFilteredList(WorkSearchModel model); + WorkViewModel? GetElement(WorkSearchModel model); + WorkViewModel? Insert(WorkBindingModel model); + WorkViewModel? Update(WorkBindingModel model); + WorkViewModel? Delete(WorkBindingModel model); + } +} diff --git a/ServiceStation/ServiceStationDataModels/IClientWorkModel.cs b/ServiceStation/ServiceStationDataModels/IClientWorkModel.cs index dd67968..e580818 100644 --- a/ServiceStation/ServiceStationDataModels/IClientWorkModel.cs +++ b/ServiceStation/ServiceStationDataModels/IClientWorkModel.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace ServiceStationDataModels { - public interface IClientWorkModel + public interface IClientStorage { int ClientId { get; } int WorkId { get; } diff --git a/ServiceStation/ServiceStationsDataBaseImplement/DataBase.cs b/ServiceStation/ServiceStationsDataBaseImplement/DataBase.cs new file mode 100644 index 0000000..c9675ae --- /dev/null +++ b/ServiceStation/ServiceStationsDataBaseImplement/DataBase.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore; +using ServiceStationsDataBaseImplement.Models; +using System.Collections.Generic; +using System.Data; + +namespace ServiceStationsDataBaseImplement +{ + public class Database : DbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder + optionsBuilder) + { + if (optionsBuilder.IsConfigured == false) + { + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-E2VPEN3\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + } + base.OnConfiguring(optionsBuilder); + } + public virtual DbSet Clients { set; get; } + + + } +} \ No newline at end of file diff --git a/ServiceStation/ServiceStationsDataBaseImplement/Implements/ClientStorage.cs b/ServiceStation/ServiceStationsDataBaseImplement/Implements/ClientStorage.cs new file mode 100644 index 0000000..d0dd51b --- /dev/null +++ b/ServiceStation/ServiceStationsDataBaseImplement/Implements/ClientStorage.cs @@ -0,0 +1,48 @@ +using ServiceStationContracts.BindingModels; +using ServiceStationContracts.SearchModels; +using ServiceStationContracts.ViewModels; +using ServiceStationsContracts.StorageContracts; + +namespace ServiceStationsDataBaseImplement.Implements +{ + public class ClientStorage : IClientStorage + { + public ClientViewModel? Delete(ClientBindingModel model) + { + using var context = new Database(); + var element = context.Clients.FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.Clients.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + + public ClientViewModel? GetElement(ClientSearchModel model) + { + throw new NotImplementedException(); + } + + public List GetFilteredList(ClientSearchModel model) + { + throw new NotImplementedException(); + } + + public List GetFullList() + { + throw new NotImplementedException(); + } + + public ClientViewModel? Insert(ClientBindingModel model) + { + throw new NotImplementedException(); + } + + public ClientViewModel? Update(ClientBindingModel model) + { + throw new NotImplementedException(); + } + } +} diff --git a/ServiceStation/ServiceStationsDataBaseImplement/ServiceStationsDataBaseImplement.csproj b/ServiceStation/ServiceStationsDataBaseImplement/ServiceStationsDataBaseImplement.csproj new file mode 100644 index 0000000..5f4e056 --- /dev/null +++ b/ServiceStation/ServiceStationsDataBaseImplement/ServiceStationsDataBaseImplement.csproj @@ -0,0 +1,22 @@ + + + + net7.0 + enable + enable + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + +