diff --git a/AutoWorkshopDatabaseImplement/AutoWorkshopDatabase.cs b/AutoWorkshopDatabaseImplement/AutoWorkshopDatabase.cs index 04cc320..43b31ee 100644 --- a/AutoWorkshopDatabaseImplement/AutoWorkshopDatabase.cs +++ b/AutoWorkshopDatabaseImplement/AutoWorkshopDatabase.cs @@ -9,7 +9,7 @@ namespace AutoWorkshopDatabaseImplement { if (OptionsBuilder.IsConfigured == false) { - OptionsBuilder.UseNpgsql(@"Host=localhost;Database=AutoWorkshop;Username=postgres;Password=admin"); + OptionsBuilder.UseNpgsql(@"Host=localhost;Database=AutoWorkshop;Port=5000;Username=postgres;Password=admin"); } base.OnConfiguring(OptionsBuilder); diff --git a/AutoWorkshopView/Forms/FormComponents.cs b/AutoWorkshopView/Forms/FormComponents.cs index bf7990f..4d9da68 100644 --- a/AutoWorkshopView/Forms/FormComponents.cs +++ b/AutoWorkshopView/Forms/FormComponents.cs @@ -1,5 +1,6 @@ using AutoWorkshopContracts.BindingModels; using AutoWorkshopContracts.BusinessLogicContracts; +using AutoWorkshopContracts.DI; using Microsoft.Extensions.Logging; namespace AutoWorkshopView.Forms @@ -37,9 +38,9 @@ namespace AutoWorkshopView.Forms private void AddButton_Click(object sender, EventArgs e) { - var Service = Program.ServiceProvider?.GetService(typeof(FormComponent)); - - if (Service is FormComponent Form) + var Service = DependencyManager.Instance.Resolve(); + + if (Service is FormComponent Form) { if (Form.ShowDialog() == DialogResult.OK) { @@ -52,8 +53,8 @@ namespace AutoWorkshopView.Forms { if (DataGridView.SelectedRows.Count == 1) { - var Service = Program.ServiceProvider?.GetService(typeof(FormComponent)); - if (Service is FormComponent Form) + var Service = DependencyManager.Instance.Resolve(); + if (Service is FormComponent Form) { Form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); if (Form.ShowDialog() == DialogResult.OK) diff --git a/AutoWorkshopView/Forms/FormImplementers.cs b/AutoWorkshopView/Forms/FormImplementers.cs index 8e511e5..1ecc1db 100644 --- a/AutoWorkshopView/Forms/FormImplementers.cs +++ b/AutoWorkshopView/Forms/FormImplementers.cs @@ -1,5 +1,6 @@ using AutoWorkshopContracts.BindingModels; using AutoWorkshopContracts.BusinessLogicsContracts; +using AutoWorkshopContracts.DI; using Microsoft.Extensions.Logging; namespace AutoWorkshopView.Forms @@ -38,9 +39,9 @@ namespace AutoWorkshopView.Forms private void AddButton_Click(object sender, EventArgs e) { - var Service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); - - if (Service is FormImplementer Form) + var Service = DependencyManager.Instance.Resolve(); + + if (Service is FormImplementer Form) { if (Form.ShowDialog() == DialogResult.OK) { @@ -53,7 +54,7 @@ namespace AutoWorkshopView.Forms { if (DataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); + var service = DependencyManager.Instance.Resolve(); if (service is FormImplementer Form) { Form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); diff --git a/AutoWorkshopView/Forms/FormRepair.cs b/AutoWorkshopView/Forms/FormRepair.cs index 8752f0f..59d0935 100644 --- a/AutoWorkshopView/Forms/FormRepair.cs +++ b/AutoWorkshopView/Forms/FormRepair.cs @@ -1,5 +1,6 @@ using AutoWorkshopContracts.BindingModels; using AutoWorkshopContracts.BusinessLogicContracts; +using AutoWorkshopContracts.DI; using AutoWorkshopContracts.SearchModels; using AutoWorkshopDataModels.Models; using Microsoft.Extensions.Logging; @@ -82,7 +83,7 @@ namespace AutoWorkshopView.Forms private void AddButton_Click(object sender, EventArgs e) { - var Service = Program.ServiceProvider?.GetService(typeof(FormRepairComponent)); + var Service = DependencyManager.Instance.Resolve(); if (Service is FormRepairComponent Form) { @@ -113,8 +114,8 @@ namespace AutoWorkshopView.Forms { if (DataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormRepairComponent)); - if (service is FormRepairComponent Form) + var service = DependencyManager.Instance.Resolve(); + if (service is FormRepairComponent Form) { int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value); Form.Id = id; diff --git a/AutoWorkshopView/Forms/FormRepairs.cs b/AutoWorkshopView/Forms/FormRepairs.cs index 75f23f6..bfb283a 100644 --- a/AutoWorkshopView/Forms/FormRepairs.cs +++ b/AutoWorkshopView/Forms/FormRepairs.cs @@ -1,5 +1,6 @@ using AutoWorkshopContracts.BindingModels; using AutoWorkshopContracts.BusinessLogicContracts; +using AutoWorkshopContracts.DI; using Microsoft.Extensions.Logging; namespace AutoWorkshopView.Forms @@ -38,7 +39,7 @@ namespace AutoWorkshopView.Forms private void AddButton_Click(object sender, EventArgs e) { - var Service = Program.ServiceProvider?.GetService(typeof(FormRepair)); + var Service = DependencyManager.Instance.Resolve(); if (Service is FormRepair Form) { @@ -53,7 +54,7 @@ namespace AutoWorkshopView.Forms { if (DataGridView.SelectedRows.Count == 1) { - var Service = Program.ServiceProvider?.GetService(typeof(FormRepair)); + var Service = DependencyManager.Instance.Resolve(); if (Service is FormRepair Form) { diff --git a/AutoWorkshopView/MainForm.cs b/AutoWorkshopView/MainForm.cs index 363a56f..7be5764 100644 --- a/AutoWorkshopView/MainForm.cs +++ b/AutoWorkshopView/MainForm.cs @@ -1,6 +1,7 @@ using AutoWorkshopContracts.BindingModels; using AutoWorkshopContracts.BusinessLogicContracts; using AutoWorkshopContracts.BusinessLogicsContracts; +using AutoWorkshopContracts.DI; using AutoWorkshopView.Forms; using Microsoft.Extensions.Logging; @@ -49,7 +50,7 @@ namespace AutoWorkshopView private void ComponentsStripMenuItem_Click(object sender, EventArgs e) { - var Service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + var Service = DependencyManager.Instance.Resolve(); if (Service is FormComponents Form) { @@ -59,7 +60,7 @@ namespace AutoWorkshopView private void RepairsStripMenuItem_Click(object sender, EventArgs e) { - var Service = Program.ServiceProvider?.GetService(typeof(FormRepairs)); + var Service = DependencyManager.Instance.Resolve(); if (Service is FormRepairs Form) { @@ -69,7 +70,7 @@ namespace AutoWorkshopView private void CreateOrderButton_Click(object sender, EventArgs e) { - var Service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + var Service = DependencyManager.Instance.Resolve(); if (Service is FormCreateOrder Form) { @@ -179,7 +180,7 @@ namespace AutoWorkshopView private void ComponentRepairToolStripMenuItem_Click(object sender, EventArgs e) { - var Service = Program.ServiceProvider?.GetService(typeof(FormReportRepairComponents)); + var Service = DependencyManager.Instance.Resolve(); if (Service is FormReportRepairComponents Form) { @@ -189,7 +190,7 @@ namespace AutoWorkshopView private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) { - var Service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + var Service = DependencyManager.Instance.Resolve(); if (Service is FormReportOrders Form) { @@ -199,7 +200,7 @@ namespace AutoWorkshopView private void ClientsToolStripMenuItem_Click(object sender, EventArgs e) { - var Service = Program.ServiceProvider?.GetService(typeof(FormClients)); + var Service = DependencyManager.Instance.Resolve(); if (Service is FormClients Form) { @@ -209,7 +210,7 @@ namespace AutoWorkshopView private void EmployersToolStripMenuItem_Click(object sender, EventArgs e) { - var Service = Program.ServiceProvider?.GetService(typeof(FormImplementers)); + var Service = DependencyManager.Instance.Resolve(); if (Service is FormImplementers Form) { @@ -219,15 +220,15 @@ namespace AutoWorkshopView private void StartWorkToolStripMenuItem_Click(object sender, EventArgs e) { - var ImplementerLogic = Program.ServiceProvider?.GetService(typeof(IImplementerLogic)); - _workProcess.DoWork((ImplementerLogic as IImplementerLogic)!, _orderLogic); + var ImplementerLogic = DependencyManager.Instance.Resolve(); + _workProcess.DoWork(ImplementerLogic, _orderLogic); MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void MailToolStripMenuItem_Click(object sender, EventArgs e) { - var Service = Program.ServiceProvider?.GetService(typeof(FormMail)); + var Service = DependencyManager.Instance.Resolve(); if (Service is FormMail Form) {