diff --git a/SecuritySystem/FormCreateOrder.Designer.cs b/SecuritySystem/FormCreateOrder.Designer.cs index 9a89b05..ba1b6eb 100644 --- a/SecuritySystem/FormCreateOrder.Designer.cs +++ b/SecuritySystem/FormCreateOrder.Designer.cs @@ -28,8 +28,8 @@ /// private void InitializeComponent() { - this.labelManufacture = new System.Windows.Forms.Label(); - this.comboBoxManufacture = new System.Windows.Forms.ComboBox(); + this.labelSecure = new System.Windows.Forms.Label(); + this.comboBoxSecure = new System.Windows.Forms.ComboBox(); this.labelCount = new System.Windows.Forms.Label(); this.textBoxCount = new System.Windows.Forms.TextBox(); this.labelSum = new System.Windows.Forms.Label(); @@ -38,23 +38,23 @@ this.buttonSave = new System.Windows.Forms.Button(); this.SuspendLayout(); // - // labelManufacture + // labelSecure // - this.labelManufacture.AutoSize = true; - this.labelManufacture.Location = new System.Drawing.Point(12, 15); - this.labelManufacture.Name = "labelManufacture"; - this.labelManufacture.Size = new System.Drawing.Size(75, 20); - this.labelManufacture.TabIndex = 0; - this.labelManufacture.Text = "Изделие: "; + this.labelSecure.AutoSize = true; + this.labelSecure.Location = new System.Drawing.Point(12, 15); + this.labelSecure.Name = "labelSecure"; + this.labelSecure.Size = new System.Drawing.Size(75, 20); + this.labelSecure.TabIndex = 0; + this.labelSecure.Text = "Изделие: "; // - // comboBoxManufacture + // comboBoxSecure // - this.comboBoxManufacture.FormattingEnabled = true; - this.comboBoxManufacture.Location = new System.Drawing.Point(115, 12); - this.comboBoxManufacture.Name = "comboBoxManufacture"; - this.comboBoxManufacture.Size = new System.Drawing.Size(358, 28); - this.comboBoxManufacture.TabIndex = 1; - this.comboBoxManufacture.SelectedIndexChanged += new System.EventHandler(this.ComboBoxManufacture_SelectedIndexChanged); + this.comboBoxSecure.FormattingEnabled = true; + this.comboBoxSecure.Location = new System.Drawing.Point(115, 12); + this.comboBoxSecure.Name = "comboBoxSecure"; + this.comboBoxSecure.Size = new System.Drawing.Size(358, 28); + this.comboBoxSecure.TabIndex = 1; + this.comboBoxSecure.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSecure_SelectedIndexChanged); // // labelCount // @@ -121,8 +121,8 @@ this.Controls.Add(this.labelSum); this.Controls.Add(this.textBoxCount); this.Controls.Add(this.labelCount); - this.Controls.Add(this.comboBoxManufacture); - this.Controls.Add(this.labelManufacture); + this.Controls.Add(this.comboBoxSecure); + this.Controls.Add(this.labelSecure); this.Name = "FormCreateOrder"; this.Text = "Заказ"; this.Load += new System.EventHandler(this.FormCreateOrder_Load); @@ -133,8 +133,8 @@ #endregion - private Label labelManufacture; - private ComboBox comboBoxManufacture; + private Label labelSecure; + private ComboBox comboBoxSecure; private Label labelCount; private TextBox textBoxCount; private Label labelSum; diff --git a/SecuritySystem/FormCreateOrder.cs b/SecuritySystem/FormCreateOrder.cs index a7ce11f..4af9c06 100644 --- a/SecuritySystem/FormCreateOrder.cs +++ b/SecuritySystem/FormCreateOrder.cs @@ -18,10 +18,10 @@ namespace SecuritySystemView public partial class FormCreateOrder : Form { private readonly ILogger _logger; - private readonly IManufactureLogic _logicM; + private readonly ISecureLogic _logicM; private readonly IOrderLogic _logicO; - private List? _list; - public FormCreateOrder(ILogger logger, IManufactureLogic logicM, IOrderLogic logicO) + private List? _list; + public FormCreateOrder(ILogger logger, ISecureLogic logicM, IOrderLogic logicO) { InitializeComponent(); _logger = logger; @@ -33,23 +33,23 @@ namespace SecuritySystemView _list = _logicM.ReadList(null); if (_list != null) { - comboBoxManufacture.DisplayMember = "ManufactureName"; - comboBoxManufacture.ValueMember = "Id"; - comboBoxManufacture.DataSource = _list; - comboBoxManufacture.SelectedItem = null; + comboBoxSecure.DisplayMember = "SecureName"; + comboBoxSecure.ValueMember = "Id"; + comboBoxSecure.DataSource = _list; + comboBoxSecure.SelectedItem = null; _logger.LogInformation("Загрузка изделий для заказа"); } } private void CalcSum() { - if (comboBoxManufacture.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + if (comboBoxSecure.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) { try { - int id = Convert.ToInt32(comboBoxManufacture.SelectedValue); - var Manufacture = _logicM.ReadElement(new ManufactureSearchModel { Id = id }); + int id = Convert.ToInt32(comboBoxSecure.SelectedValue); + var Secure = _logicM.ReadElement(new SecureSearchModel { Id = id }); int count = Convert.ToInt32(textBoxCount.Text); - textBoxSum.Text = Math.Round(count * (Manufacture?.Price ?? 0), 2).ToString(); + textBoxSum.Text = Math.Round(count * (Secure?.Price ?? 0), 2).ToString(); _logger.LogInformation("Расчет суммы заказа"); } catch (Exception ex) @@ -63,7 +63,7 @@ namespace SecuritySystemView { CalcSum(); } - private void ComboBoxManufacture_SelectedIndexChanged(object sender, EventArgs e) + private void ComboBoxSecure_SelectedIndexChanged(object sender, EventArgs e) { CalcSum(); } @@ -74,7 +74,7 @@ namespace SecuritySystemView MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (comboBoxManufacture.SelectedValue == null) + if (comboBoxSecure.SelectedValue == null) { MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -84,8 +84,8 @@ namespace SecuritySystemView { var operationResult = _logicO.CreateOrder(new OrderBindingModel { - ManufactureId = Convert.ToInt32(comboBoxManufacture.SelectedValue), - ManufactureName = comboBoxManufacture.Text, + SecureId = Convert.ToInt32(comboBoxSecure.SelectedValue), + SecureName = comboBoxSecure.Text, Count = Convert.ToInt32(textBoxCount.Text), Sum = Convert.ToDouble(textBoxSum.Text) }); diff --git a/SecuritySystem/FormMain.cs b/SecuritySystem/FormMain.cs index 6ce123b..2537a2f 100644 --- a/SecuritySystem/FormMain.cs +++ b/SecuritySystem/FormMain.cs @@ -37,8 +37,8 @@ namespace SecuritySystemView if (list != null) { dataGridView.DataSource = list; - dataGridView.Columns["ManufactureId"].Visible = false; - dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["SecureId"].Visible = false; + dataGridView.Columns["SecureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); } @@ -58,8 +58,8 @@ namespace SecuritySystemView } private void GoodsToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufacturies)); - if (service is FormManufacturies form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecuries)); + if (service is FormSecuries form) { form.ShowDialog(); } @@ -84,8 +84,8 @@ namespace SecuritySystemView var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value), + SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), @@ -115,8 +115,8 @@ namespace SecuritySystemView var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value), + SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), @@ -147,8 +147,8 @@ namespace SecuritySystemView var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id, - ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), - ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), + SecureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SecureId"].Value), + SecureName = dataGridView.SelectedRows[0].Cells["SecureName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), diff --git a/SecuritySystem/FormManufacturies.resx b/SecuritySystem/FormManufacturies.resx deleted file mode 100644 index 1af7de1..0000000 --- a/SecuritySystem/FormManufacturies.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SecuritySystem/FormManufacture.Designer.cs b/SecuritySystem/FormSecure.Designer.cs similarity index 98% rename from SecuritySystem/FormManufacture.Designer.cs rename to SecuritySystem/FormSecure.Designer.cs index d4283d0..934e2e7 100644 --- a/SecuritySystem/FormManufacture.Designer.cs +++ b/SecuritySystem/FormSecure.Designer.cs @@ -1,6 +1,6 @@ namespace SecuritySystemView { - partial class FormManufacture + partial class FormSecure { /// /// Required designer variable. @@ -38,11 +38,11 @@ this.buttonUpd = new System.Windows.Forms.Button(); this.buttonAdd = new System.Windows.Forms.Button(); this.dataGridView = new System.Windows.Forms.DataGridView(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonSave = new System.Windows.Forms.Button(); this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); this.groupBoxComponents.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -76,6 +76,7 @@ // this.textBoxPrice.Location = new System.Drawing.Point(112, 51); this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.ReadOnly = true; this.textBoxPrice.Size = new System.Drawing.Size(171, 27); this.textBoxPrice.TabIndex = 3; // @@ -151,26 +152,6 @@ this.dataGridView.Size = new System.Drawing.Size(476, 287); this.dataGridView.TabIndex = 0; // - // buttonCancel - // - this.buttonCancel.Location = new System.Drawing.Point(514, 417); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(126, 34); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "Отмена"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); - // - // buttonSave - // - this.buttonSave.Location = new System.Drawing.Point(368, 417); - this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(126, 34); - this.buttonSave.TabIndex = 6; - this.buttonSave.Text = "Сохранить"; - this.buttonSave.UseVisualStyleBackColor = true; - this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); - // // id // this.id.HeaderText = "id"; @@ -193,6 +174,26 @@ this.Count.Name = "Count"; this.Count.ReadOnly = true; // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(514, 417); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(126, 34); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(368, 417); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(126, 34); + this.buttonSave.TabIndex = 6; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // // FormManufacture // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); @@ -207,7 +208,7 @@ this.Controls.Add(this.labelName); this.Name = "FormManufacture"; this.Text = "Изделие"; - this.Load += new System.EventHandler(this.FormManufacture_Load); + this.Load += new System.EventHandler(this.FormSecure_Load); this.groupBoxComponents.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/SecuritySystem/FormManufacture.cs b/SecuritySystem/FormSecure.cs similarity index 79% rename from SecuritySystem/FormManufacture.cs rename to SecuritySystem/FormSecure.cs index 0a6a1a6..f328329 100644 --- a/SecuritySystem/FormManufacture.cs +++ b/SecuritySystem/FormSecure.cs @@ -16,33 +16,33 @@ using System.Windows.Forms; namespace SecuritySystemView { - public partial class FormManufacture : Form + public partial class FormSecure : Form { private readonly ILogger _logger; - private readonly IManufactureLogic _logic; + private readonly ISecureLogic _logic; private int? _id; - private Dictionary _ManufactureComponents; + private Dictionary _SecureComponents; public int Id { set { _id = value; } } - public FormManufacture(ILogger logger, IManufactureLogic logic) + public FormSecure(ILogger logger, ISecureLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; - _ManufactureComponents = new Dictionary(); + _SecureComponents = new Dictionary(); } - private void FormManufacture_Load(object sender, EventArgs e) + private void FormSecure_Load(object sender, EventArgs e) { if (_id.HasValue) { _logger.LogInformation("Загрузка изделия"); try { - var view = _logic.ReadElement(new ManufactureSearchModel { Id = _id.Value }); + var view = _logic.ReadElement(new SecureSearchModel { Id = _id.Value }); if (view != null) { - textBoxName.Text = view.ManufactureName; + textBoxName.Text = view.SecureName; textBoxPrice.Text = view.Price.ToString(); - _ManufactureComponents = view.ManufactureComponents ?? new + _SecureComponents = view.SecureComponents ?? new Dictionary(); LoadData(); } @@ -60,10 +60,10 @@ namespace SecuritySystemView _logger.LogInformation("Загрузка компонент изделия"); try { - if (_ManufactureComponents != null) + if (_SecureComponents != null) { dataGridView.Rows.Clear(); - foreach (var pc in _ManufactureComponents) + foreach (var pc in _SecureComponents) { dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); } @@ -79,8 +79,8 @@ namespace SecuritySystemView } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent)); - if (service is FormManufactureComponent form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecuriesComponent)); + if (service is FormSecuriesComponent form) { if (form.ShowDialog() == DialogResult.OK) { @@ -89,13 +89,13 @@ namespace SecuritySystemView return; } _logger.LogInformation("Добавление нового компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); - if (_ManufactureComponents.ContainsKey(form.Id)) + if (_SecureComponents.ContainsKey(form.Id)) { - _ManufactureComponents[form.Id] = (form.ComponentModel, form.Count); + _SecureComponents[form.Id] = (form.ComponentModel, form.Count); } else { - _ManufactureComponents.Add(form.Id, (form.ComponentModel, form.Count)); + _SecureComponents.Add(form.Id, (form.ComponentModel, form.Count)); } LoadData(); } @@ -105,12 +105,12 @@ namespace SecuritySystemView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent)); - if (service is FormManufactureComponent form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecuriesComponent)); + if (service is FormSecuriesComponent form) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); form.Id = id; - form.Count = _ManufactureComponents[id].Item2; + form.Count = _SecureComponents[id].Item2; if (form.ShowDialog() == DialogResult.OK) { if (form.ComponentModel == null) @@ -118,7 +118,7 @@ namespace SecuritySystemView return; } _logger.LogInformation("Изменение компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); - _ManufactureComponents[form.Id] = (form.ComponentModel, form.Count); + _SecureComponents[form.Id] = (form.ComponentModel, form.Count); LoadData(); } } @@ -134,7 +134,7 @@ namespace SecuritySystemView try { _logger.LogInformation("Удаление компонента: {ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); - _ManufactureComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + _SecureComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); } catch (Exception ex) { @@ -161,7 +161,7 @@ namespace SecuritySystemView MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (_ManufactureComponents == null || _ManufactureComponents.Count == 0) + if (_SecureComponents == null || _SecureComponents.Count == 0) { MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -169,12 +169,12 @@ namespace SecuritySystemView _logger.LogInformation("Сохранение изделия"); try { - var model = new ManufactureBindingModel + var model = new SecureBindingModel { Id = _id ?? 0, - ManufactureName = textBoxName.Text, + SecureName = textBoxName.Text, Price = Convert.ToDouble(textBoxPrice.Text), - ManufactureComponents = _ManufactureComponents + SecureComponents = _SecureComponents }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) @@ -199,7 +199,7 @@ namespace SecuritySystemView private double CalcPrice() { double price = 0; - foreach (var elem in _ManufactureComponents) + foreach (var elem in _SecureComponents) { price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); } diff --git a/SecuritySystem/FormSecure.resx b/SecuritySystem/FormSecure.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SecuritySystem/FormSecure.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SecuritySystem/FormManufacturies.Designer.cs b/SecuritySystem/FormSecuries.Designer.cs similarity index 96% rename from SecuritySystem/FormManufacturies.Designer.cs rename to SecuritySystem/FormSecuries.Designer.cs index 5147d93..718eb7d 100644 --- a/SecuritySystem/FormManufacturies.Designer.cs +++ b/SecuritySystem/FormSecuries.Designer.cs @@ -1,6 +1,6 @@ namespace SecuritySystemView { - partial class FormManufacturies + partial class FormSecuries { /// /// Required designer variable. @@ -102,16 +102,16 @@ this.dataGridView.Size = new System.Drawing.Size(590, 426); this.dataGridView.TabIndex = 2; // - // FormManufacturies + // FormSecure // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); this.Controls.Add(this.ToolsPanel); this.Controls.Add(this.dataGridView); - this.Name = "FormManufacturies"; + this.Name = "FormSecuries"; this.Text = "Изделия"; - this.Load += new System.EventHandler(this.FormManufacturies_Load); + this.Load += new System.EventHandler(this.FormSecuries_Load); this.ToolsPanel.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/SecuritySystem/FormManufacturies.cs b/SecuritySystem/FormSecuries.cs similarity index 83% rename from SecuritySystem/FormManufacturies.cs rename to SecuritySystem/FormSecuries.cs index 61d79fc..acd9911 100644 --- a/SecuritySystem/FormManufacturies.cs +++ b/SecuritySystem/FormSecuries.cs @@ -14,17 +14,17 @@ using System.Windows.Forms; namespace SecuritySystemView { - public partial class FormManufacturies : Form + public partial class FormSecuries : Form { private readonly ILogger _logger; - private readonly IManufactureLogic _logic; - public FormManufacturies(ILogger logger, IManufactureLogic logic) + private readonly ISecureLogic _logic; + public FormSecuries(ILogger logger, ISecureLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; } - private void FormManufacturies_Load(object sender, EventArgs e) + private void FormSecuries_Load(object sender, EventArgs e) { LoadData(); } @@ -37,8 +37,8 @@ namespace SecuritySystemView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ManufactureComponents"].Visible = false; - dataGridView.Columns["ManufactureName"].AutoSizeMode = + dataGridView.Columns["SecureComponents"].Visible = false; + dataGridView.Columns["SecureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка изделий"); @@ -51,8 +51,8 @@ namespace SecuritySystemView } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufacture)); - if (service is FormManufacture form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecure)); + if (service is FormSecure form) { if (form.ShowDialog() == DialogResult.OK) { @@ -64,8 +64,8 @@ namespace SecuritySystemView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormManufacture)); - if (service is FormManufacture form) + var service = Program.ServiceProvider?.GetService(typeof(FormSecure)); + if (service is FormSecure form) { form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) @@ -85,7 +85,7 @@ namespace SecuritySystemView _logger.LogInformation("Удаление изделия"); try { - if (!_logic.Delete(new ManufactureBindingModel { Id = id })) + if (!_logic.Delete(new SecureBindingModel { Id = id })) { throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); } diff --git a/SecuritySystem/FormManufacture.resx b/SecuritySystem/FormSecuries.resx similarity index 100% rename from SecuritySystem/FormManufacture.resx rename to SecuritySystem/FormSecuries.resx diff --git a/SecuritySystem/FormManufactureComponent.Designer.cs b/SecuritySystem/FormSecuriesComponent.Designer.cs similarity index 99% rename from SecuritySystem/FormManufactureComponent.Designer.cs rename to SecuritySystem/FormSecuriesComponent.Designer.cs index 686592c..bb2b8c6 100644 --- a/SecuritySystem/FormManufactureComponent.Designer.cs +++ b/SecuritySystem/FormSecuriesComponent.Designer.cs @@ -1,6 +1,6 @@ namespace SecuritySystemView { - partial class FormManufactureComponent + partial class FormSecuriesComponent { /// /// Required designer variable. diff --git a/SecuritySystem/FormManufactureComponent.cs b/SecuritySystem/FormSecuriesComponent.cs similarity index 95% rename from SecuritySystem/FormManufactureComponent.cs rename to SecuritySystem/FormSecuriesComponent.cs index cdf9c1a..ad94391 100644 --- a/SecuritySystem/FormManufactureComponent.cs +++ b/SecuritySystem/FormSecuriesComponent.cs @@ -13,7 +13,7 @@ using System.Windows.Forms; namespace SecuritySystemView { - public partial class FormManufactureComponent : Form + public partial class FormSecuriesComponent : Form { private readonly List? _list; public int Id @@ -50,7 +50,7 @@ namespace SecuritySystemView get { return Convert.ToInt32(textBoxCount.Text); } set { textBoxCount.Text = value.ToString(); } } - public FormManufactureComponent(IComponentLogic logic) + public FormSecuriesComponent(IComponentLogic logic) { InitializeComponent(); _list = logic.ReadList(null); diff --git a/SecuritySystem/FormManufactureComponent.resx b/SecuritySystem/FormSecuriesComponent.resx similarity index 100% rename from SecuritySystem/FormManufactureComponent.resx rename to SecuritySystem/FormSecuriesComponent.resx diff --git a/SecuritySystem/Program.cs b/SecuritySystem/Program.cs index f6d0b1d..e49e574 100644 --- a/SecuritySystem/Program.cs +++ b/SecuritySystem/Program.cs @@ -40,17 +40,17 @@ namespace SecuritySystem services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/SecuritySystemContracts/BindingModels/OrderBindingModel.cs b/SecuritySystemContracts/BindingModels/OrderBindingModel.cs index eccc6bf..ae51c4c 100644 --- a/SecuritySystemContracts/BindingModels/OrderBindingModel.cs +++ b/SecuritySystemContracts/BindingModels/OrderBindingModel.cs @@ -6,10 +6,10 @@ namespace SecuritySystemContracts.BindingModels public class OrderBindingModel : IOrderModel { public int Id { get; set; } - public int ManufactureId { get; set; } + public int SecureId { get; set; } public int Count { get; set; } public double Sum { get; set; } - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime? DateImplement { get; set; } diff --git a/SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs b/SecuritySystemContracts/BindingModels/SecureBindingModel.cs similarity index 54% rename from SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs rename to SecuritySystemContracts/BindingModels/SecureBindingModel.cs index 408ec7a..2a24bee 100644 --- a/SecuritySystemContracts/BindingModels/ManufactureBindingModel.cs +++ b/SecuritySystemContracts/BindingModels/SecureBindingModel.cs @@ -3,12 +3,12 @@ using SecuritySystemDataModels.Models; namespace SecuritySystemContracts.BindingModels { - public class ManufactureBindingModel : IManufactureModel + public class SecureBindingModel : ISecureModel { public int Id { get; set; } - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; public double Price { get; set; } - public Dictionary ManufactureComponents + public Dictionary SecureComponents { get; set; diff --git a/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs b/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs deleted file mode 100644 index 35eaabc..0000000 --- a/SecuritySystemContracts/BusinessLogicsContracts/IManufactureLogic.cs +++ /dev/null @@ -1,21 +0,0 @@ -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.ViewModels; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SecuritySystemContracts.BusinessLogicsContracts -{ - public interface IManufactureLogic - { - List? ReadList(ManufactureSearchModel? model); - ManufactureViewModel? ReadElement(ManufactureSearchModel model); - bool Create(ManufactureBindingModel model); - bool Update(ManufactureBindingModel model); - bool Delete(ManufactureBindingModel model); - } -} diff --git a/SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs b/SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs new file mode 100644 index 0000000..58f0398 --- /dev/null +++ b/SecuritySystemContracts/BusinessLogicsContracts/ISecureLogic.cs @@ -0,0 +1,21 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.BusinessLogicsContracts +{ + public interface ISecureLogic + { + List? ReadList(SecureSearchModel? model); + SecureViewModel? ReadElement(SecureSearchModel model); + bool Create(SecureBindingModel model); + bool Update(SecureBindingModel model); + bool Delete(SecureBindingModel model); + } +} diff --git a/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs b/SecuritySystemContracts/SearchModels/SecureSearchModel.cs similarity index 70% rename from SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs rename to SecuritySystemContracts/SearchModels/SecureSearchModel.cs index 2613f72..ea906d3 100644 --- a/SecuritySystemContracts/SearchModels/ManufactureSearchModel.cs +++ b/SecuritySystemContracts/SearchModels/SecureSearchModel.cs @@ -6,9 +6,9 @@ using System.Threading.Tasks; namespace SecuritySystemContracts.SearchModels { - public class ManufactureSearchModel + public class SecureSearchModel { public int? Id { get; set; } - public string? ManufactureName { get; set; } + public string? SecureName { get; set; } } } diff --git a/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs b/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs deleted file mode 100644 index dd0c521..0000000 --- a/SecuritySystemContracts/StorageContracts/IManufactureStorage.cs +++ /dev/null @@ -1,21 +0,0 @@ -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SecuritySystemContracts.StoragesContracts -{ - public interface IManufactureStorage - { - List GetFullList(); - List GetFilteredList(ManufactureSearchModel model); - ManufactureViewModel? GetElement(ManufactureSearchModel model); - ManufactureViewModel? Insert(ManufactureBindingModel model); - ManufactureViewModel? Update(ManufactureBindingModel model); - ManufactureViewModel? Delete(ManufactureBindingModel model); - } -} diff --git a/SecuritySystemContracts/StorageContracts/ISecureStorage.cs b/SecuritySystemContracts/StorageContracts/ISecureStorage.cs new file mode 100644 index 0000000..7dc62cc --- /dev/null +++ b/SecuritySystemContracts/StorageContracts/ISecureStorage.cs @@ -0,0 +1,21 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SecuritySystemContracts.StoragesContracts +{ + public interface ISecureStorage + { + List GetFullList(); + List GetFilteredList(SecureSearchModel model); + SecureViewModel? GetElement(SecureSearchModel model); + SecureViewModel? Insert(SecureBindingModel model); + SecureViewModel? Update(SecureBindingModel model); + SecureViewModel? Delete(SecureBindingModel model); + } +} diff --git a/SecuritySystemContracts/ViewModels/OrderViewModel.cs b/SecuritySystemContracts/ViewModels/OrderViewModel.cs index 79b07cb..498fcbf 100644 --- a/SecuritySystemContracts/ViewModels/OrderViewModel.cs +++ b/SecuritySystemContracts/ViewModels/OrderViewModel.cs @@ -13,9 +13,9 @@ namespace SecuritySystemContracts.ViewModels { [DisplayName("Номер")] public int Id { get; set; } - public int ManufactureId { get; set; } + public int SecureId { get; set; } [DisplayName("Изделие")] - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; [DisplayName("Количество")] public int Count { get; set; } [DisplayName("Сумма")] diff --git a/SecuritySystemContracts/ViewModels/ManufactureViewModel.cs b/SecuritySystemContracts/ViewModels/SecureViewModel.cs similarity index 70% rename from SecuritySystemContracts/ViewModels/ManufactureViewModel.cs rename to SecuritySystemContracts/ViewModels/SecureViewModel.cs index c8bfd3e..4480475 100644 --- a/SecuritySystemContracts/ViewModels/ManufactureViewModel.cs +++ b/SecuritySystemContracts/ViewModels/SecureViewModel.cs @@ -8,14 +8,14 @@ using System.Threading.Tasks; namespace SecuritySystemContracts.ViewModels { - public class ManufactureViewModel : IManufactureModel + public class SecureViewModel : ISecureModel { public int Id { get; set; } [DisplayName("Название изделия")] - public string ManufactureName { get; set; } = string.Empty; + public string SecureName { get; set; } = string.Empty; [DisplayName("Цена")] public double Price { get; set; } - public Dictionary ManufactureComponents + public Dictionary SecureComponents { get; set; diff --git a/SecuritySystemDataModels/Models/IOrderModel.cs b/SecuritySystemDataModels/Models/IOrderModel.cs index 13baf8c..1f705ee 100644 --- a/SecuritySystemDataModels/Models/IOrderModel.cs +++ b/SecuritySystemDataModels/Models/IOrderModel.cs @@ -10,7 +10,7 @@ namespace SecuritySystemDataModels.Models { public interface IOrderModel : IId { - int ManufactureId { get; } + int SecureId { get; } int Count { get; } double Sum { get; } OrderStatus Status { get; } diff --git a/SecuritySystemDataModels/Models/IManufactureModel.cs b/SecuritySystemDataModels/Models/ISecureModel.cs similarity index 59% rename from SecuritySystemDataModels/Models/IManufactureModel.cs rename to SecuritySystemDataModels/Models/ISecureModel.cs index 3499105..f675b0f 100644 --- a/SecuritySystemDataModels/Models/IManufactureModel.cs +++ b/SecuritySystemDataModels/Models/ISecureModel.cs @@ -7,10 +7,10 @@ using System.Threading.Tasks; namespace SecuritySystemDataModels.Models { - public interface IManufactureModel : IId + public interface ISecureModel : IId { - string ManufactureName { get; } + string SecureName { get; } double Price { get; } - Dictionary ManufactureComponents { get; } + Dictionary SecureComponents { get; } } } diff --git a/SecuritySystemListImplement/DataListSingletone.cs b/SecuritySystemListImplement/DataListSingletone.cs index da37d1f..7a9a84a 100644 --- a/SecuritySystemListImplement/DataListSingletone.cs +++ b/SecuritySystemListImplement/DataListSingletone.cs @@ -13,12 +13,12 @@ namespace SecuritySystemListImplement private static DataListSingleton? _instance; public List Components { get; set; } public List Orders { get; set; } - public List Manufactures { get; set; } + public List Securies { get; set; } private DataListSingleton() { Components = new List(); Orders = new List(); - Manufactures = new List(); + Securies = new List(); } public static DataListSingleton GetInstance() { diff --git a/SecuritySystemListImplement/Implements/ManufactureStorage.cs b/SecuritySystemListImplement/Implements/ManufactureStorage.cs deleted file mode 100644 index 5a8ea83..0000000 --- a/SecuritySystemListImplement/Implements/ManufactureStorage.cs +++ /dev/null @@ -1,102 +0,0 @@ -using SecuritySystemListImplement.Models; -using SecuritySystemContracts.BindingModels; -using SecuritySystemContracts.SearchModels; -using SecuritySystemContracts.StoragesContracts; -using SecuritySystemContracts.ViewModels; - - -namespace SecuritySystemListImplement.Implements -{ - public class ManufactureStorage : IManufactureStorage - { - private readonly DataListSingleton _source; - public ManufactureStorage() - { - _source = DataListSingleton.GetInstance(); - } - public List GetFullList() - { - var result = new List(); - foreach (var Manufacture in _source.Manufactures) - { - result.Add(Manufacture.GetViewModel); - } - return result; - } - public List GetFilteredList(ManufactureSearchModel model) - { - var result = new List(); - if (string.IsNullOrEmpty(model.ManufactureName)) - { - return result; - } - foreach (var Manufacture in _source.Manufactures) - { - if (Manufacture.ManufactureName.Contains(model.ManufactureName)) - { - result.Add(Manufacture.GetViewModel); - } - } - return result; - } - public ManufactureViewModel? GetElement(ManufactureSearchModel model) - { - if (string.IsNullOrEmpty(model.ManufactureName) && !model.Id.HasValue) - { - return null; - } - foreach (var Manufacture in _source.Manufactures) - { - if ((!string.IsNullOrEmpty(model.ManufactureName) && Manufacture.ManufactureName == model.ManufactureName) || - (model.Id.HasValue && Manufacture.Id == model.Id)) - { - return Manufacture.GetViewModel; - } - } - return null; - } - public ManufactureViewModel? Insert(ManufactureBindingModel model) - { - model.Id = 1; - foreach (var Manufacture in _source.Manufactures) - { - if (model.Id <= Manufacture.Id) - { - model.Id = Manufacture.Id + 1; - } - } - var newManufacture = Manufacture.Create(model); - if (newManufacture == null) - { - return null; - } - _source.Manufactures.Add(newManufacture); - return newManufacture.GetViewModel; - } - public ManufactureViewModel? Update(ManufactureBindingModel model) - { - foreach (var Manufacture in _source.Manufactures) - { - if (Manufacture.Id == model.Id) - { - Manufacture.Update(model); - return Manufacture.GetViewModel; - } - } - return null; - } - public ManufactureViewModel? Delete(ManufactureBindingModel model) - { - for (int i = 0; i < _source.Manufactures.Count; ++i) - { - if (_source.Manufactures[i].Id == model.Id) - { - var element = _source.Manufactures[i]; - _source.Manufactures.RemoveAt(i); - return element.GetViewModel; - } - } - return null; - } - } -} diff --git a/SecuritySystemListImplement/Implements/OrderStorage.cs b/SecuritySystemListImplement/Implements/OrderStorage.cs index 873ed51..706ee4b 100644 --- a/SecuritySystemListImplement/Implements/OrderStorage.cs +++ b/SecuritySystemListImplement/Implements/OrderStorage.cs @@ -98,13 +98,13 @@ namespace OrdersShopListImplement.Implements } return null; } - private OrderViewModel AttachManufactureName(OrderViewModel model) + private OrderViewModel AttachSecureName(OrderViewModel model) { - foreach (var manufacture in _source.Manufactures) + foreach (var secure in _source.Securies) { - if (manufacture.Id == model.ManufactureId) + if (secure.Id == model.SecureId) { - model.ManufactureName = manufacture.ManufactureName; + model.SecureName = secure.SecureName; return model; } } diff --git a/SecuritySystemListImplement/Implements/SecureStorage.cs b/SecuritySystemListImplement/Implements/SecureStorage.cs new file mode 100644 index 0000000..a01cbf9 --- /dev/null +++ b/SecuritySystemListImplement/Implements/SecureStorage.cs @@ -0,0 +1,102 @@ +using SecuritySystemListImplement.Models; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemContracts.ViewModels; + + +namespace SecuritySystemListImplement.Implements +{ + public class SecureStorage : ISecureStorage + { + private readonly DataListSingleton _source; + public SecureStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var Secure in _source.Securies) + { + result.Add(Secure.GetViewModel); + } + return result; + } + public List GetFilteredList(SecureSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.SecureName)) + { + return result; + } + foreach (var Secure in _source.Securies) + { + if (Secure.SecureName.Contains(model.SecureName)) + { + result.Add(Secure.GetViewModel); + } + } + return result; + } + public SecureViewModel? GetElement(SecureSearchModel model) + { + if (string.IsNullOrEmpty(model.SecureName) && !model.Id.HasValue) + { + return null; + } + foreach (var Secure in _source.Securies) + { + if ((!string.IsNullOrEmpty(model.SecureName) && Secure.SecureName == model.SecureName) || + (model.Id.HasValue && Secure.Id == model.Id)) + { + return Secure.GetViewModel; + } + } + return null; + } + public SecureViewModel? Insert(SecureBindingModel model) + { + model.Id = 1; + foreach (var Secure in _source.Securies) + { + if (model.Id <= Secure.Id) + { + model.Id = Secure.Id + 1; + } + } + var newSecure = Secure.Create(model); + if (newSecure == null) + { + return null; + } + _source.Securies.Add(newSecure); + return newSecure.GetViewModel; + } + public SecureViewModel? Update(SecureBindingModel model) + { + foreach (var Secure in _source.Securies) + { + if (Secure.Id == model.Id) + { + Secure.Update(model); + return Secure.GetViewModel; + } + } + return null; + } + public SecureViewModel? Delete(SecureBindingModel model) + { + for (int i = 0; i < _source.Securies.Count; ++i) + { + if (_source.Securies[i].Id == model.Id) + { + var element = _source.Securies[i]; + _source.Securies.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/SecuritySystemListImplement/Models/Order.cs b/SecuritySystemListImplement/Models/Order.cs index caac226..2fd9e3c 100644 --- a/SecuritySystemListImplement/Models/Order.cs +++ b/SecuritySystemListImplement/Models/Order.cs @@ -15,9 +15,9 @@ namespace SecuritySystemListImplement.Models { public int Id { get; private set; } - public int ManufactureId { get; private set; } + public int SecureId { get; private set; } - public string ManufactureName { get; private set; } = string.Empty; + public string SecureName { get; private set; } = string.Empty; public int Count { get; private set; } public double Sum { get; private set; } @@ -36,7 +36,13 @@ namespace SecuritySystemListImplement.Models } return new Order() { + Id = model.Id, + SecureId = model.SecureId, + SecureName = model.SecureName, + Count = model.Count, + Sum = model.Sum, Status = model.Status, + DateCreate = model.DateCreate, DateImplement = model.DateImplement }; } @@ -47,19 +53,15 @@ namespace SecuritySystemListImplement.Models { return; } - ManufactureId = model.ManufactureId; - ManufactureName = model.ManufactureName; - Count = model.Count; - Sum = model.Sum; + Status = model.Status; - DateCreate = model.DateCreate; DateImplement = model.DateImplement; } public OrderViewModel GetViewModel => new() { Id = Id, - ManufactureId = ManufactureId, - ManufactureName = ManufactureName, + SecureId = SecureId, + SecureName = SecureName, Count = Count, Sum = Sum, Status = Status, diff --git a/SecuritySystemListImplement/Models/Manufacture.cs b/SecuritySystemListImplement/Models/Secure.cs similarity index 54% rename from SecuritySystemListImplement/Models/Manufacture.cs rename to SecuritySystemListImplement/Models/Secure.cs index 2e1deb9..28e0c76 100644 --- a/SecuritySystemListImplement/Models/Manufacture.cs +++ b/SecuritySystemListImplement/Models/Secure.cs @@ -10,46 +10,46 @@ using SecuritySystemDataModels.Models; namespace SecuritySystemListImplement.Models { - public class Manufacture : IManufactureModel + public class Secure : ISecureModel { public int Id { get; private set; } - public string ManufactureName { get; private set; } = string.Empty; + public string SecureName { get; private set; } = string.Empty; public double Price { get; private set; } - public Dictionary ManufactureComponents + public Dictionary SecureComponents { get; private set; } = new Dictionary(); - public static Manufacture? Create(ManufactureBindingModel? model) + public static Secure? Create(SecureBindingModel? model) { if (model == null) { return null; } - return new Manufacture() + return new Secure() { Id = model.Id, - ManufactureName = model.ManufactureName, + SecureName = model.SecureName, Price = model.Price, - ManufactureComponents = model.ManufactureComponents + SecureComponents = model.SecureComponents }; } - public void Update(ManufactureBindingModel? model) + public void Update(SecureBindingModel? model) { if (model == null) { return; } - ManufactureName = model.ManufactureName; + SecureName = model.SecureName; Price = model.Price; - ManufactureComponents = model.ManufactureComponents; + SecureComponents = model.SecureComponents; } - public ManufactureViewModel GetViewModel => new() + public SecureViewModel GetViewModel => new() { Id = Id, - ManufactureName = ManufactureName, + SecureName = SecureName, Price = Price, - ManufactureComponents = ManufactureComponents + SecureComponents = SecureComponents }; } } diff --git a/SystemSecurityBusinessLogic/OrderLogic.cs b/SystemSecurityBusinessLogic/OrderLogic.cs index edd9141..41cc69a 100644 --- a/SystemSecurityBusinessLogic/OrderLogic.cs +++ b/SystemSecurityBusinessLogic/OrderLogic.cs @@ -75,9 +75,9 @@ namespace SecuritySystemBusinessLogic { return; } - if (model.ManufactureId < 0) + if (model.SecureId < 0) { - throw new ArgumentNullException("Некорректный идентификатор камеры", nameof(model.ManufactureId)); + throw new ArgumentNullException("Некорректный идентификатор камеры", nameof(model.SecureId)); } if (model.Count <= 0) { @@ -87,7 +87,7 @@ namespace SecuritySystemBusinessLogic { throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum)); } - _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. ManufactureId: { ManufactureId}", model.Id, model.Sum, model.ManufactureId); + _logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. SecureId: { SecureId}", model.Id, model.Sum, model.SecureId); } private bool CheckStatus(OrderBindingModel model, OrderStatus newstatus, bool update = true) diff --git a/SystemSecurityBusinessLogic/ManufactureLogic.cs b/SystemSecurityBusinessLogic/SecureLogic.cs similarity index 59% rename from SystemSecurityBusinessLogic/ManufactureLogic.cs rename to SystemSecurityBusinessLogic/SecureLogic.cs index 26b88ab..78f5cc0 100644 --- a/SystemSecurityBusinessLogic/ManufactureLogic.cs +++ b/SystemSecurityBusinessLogic/SecureLogic.cs @@ -8,21 +8,21 @@ using Microsoft.Extensions.Logging; namespace SecuritySystemBusinessLogic { - public class ManufactureLogic : IManufactureLogic + public class SecureLogic : ISecureLogic { private readonly ILogger _logger; - private readonly IManufactureStorage _ManufactureStorage; + private readonly ISecureStorage _SecureStorage; - public ManufactureLogic(ILogger logger, IManufactureStorage ManufactureStorage) + public SecureLogic(ILogger logger, ISecureStorage SecureStorage) { _logger = logger; - _ManufactureStorage = ManufactureStorage; + _SecureStorage = SecureStorage; } - public List? ReadList(ManufactureSearchModel? model) + public List? ReadList(SecureSearchModel? model) { - _logger.LogInformation("ReadList. ManufactureName:{ManufactureName}.Id:{ Id}", model?.ManufactureName, model?.Id); - var list = model == null ? _ManufactureStorage.GetFullList() : _ManufactureStorage.GetFilteredList(model); + _logger.LogInformation("ReadList. SecureName:{SecureName}.Id:{ Id}", model?.SecureName, model?.Id); + var list = model == null ? _SecureStorage.GetFullList() : _SecureStorage.GetFilteredList(model); if (list == null) { _logger.LogWarning("ReadList return null list"); @@ -32,14 +32,14 @@ namespace SecuritySystemBusinessLogic return list; } - public ManufactureViewModel? ReadElement(ManufactureSearchModel model) + public SecureViewModel? ReadElement(SecureSearchModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. ManufactureName:{ManufactureName}.Id:{ Id}", model.ManufactureName, model.Id); - var element = _ManufactureStorage.GetElement(model); + _logger.LogInformation("ReadElement. SecureName:{SecureName}.Id:{ Id}", model.SecureName, model.Id); + var element = _SecureStorage.GetElement(model); if (element == null) { _logger.LogWarning("ReadElement element not found"); @@ -49,10 +49,10 @@ namespace SecuritySystemBusinessLogic return element; } - public bool Create(ManufactureBindingModel model) + public bool Create(SecureBindingModel model) { CheckModel(model); - if (_ManufactureStorage.Insert(model) == null) + if (_SecureStorage.Insert(model) == null) { _logger.LogWarning("Insert operation failed"); return false; @@ -60,10 +60,10 @@ namespace SecuritySystemBusinessLogic return true; } - public bool Update(ManufactureBindingModel model) + public bool Update(SecureBindingModel model) { CheckModel(model); - if (_ManufactureStorage.Update(model) == null) + if (_SecureStorage.Update(model) == null) { _logger.LogWarning("Update operation failed"); return false; @@ -71,11 +71,11 @@ namespace SecuritySystemBusinessLogic return true; } - public bool Delete(ManufactureBindingModel model) + public bool Delete(SecureBindingModel model) { CheckModel(model, false); _logger.LogInformation("Delete. Id:{Id}", model.Id); - if (_ManufactureStorage.Delete(model) == null) + if (_SecureStorage.Delete(model) == null) { _logger.LogWarning("Delete operation failed"); return false; @@ -83,7 +83,7 @@ namespace SecuritySystemBusinessLogic return true; } - private void CheckModel(ManufactureBindingModel model, bool withParams = true) + private void CheckModel(SecureBindingModel model, bool withParams = true) { if (model == null) { @@ -93,18 +93,18 @@ namespace SecuritySystemBusinessLogic { return; } - if (string.IsNullOrEmpty(model.ManufactureName)) + if (string.IsNullOrEmpty(model.SecureName)) { - throw new ArgumentNullException("Нет названия камеры", nameof(model.ManufactureName)); + throw new ArgumentNullException("Нет названия камеры", nameof(model.SecureName)); } if (model.Price <= 0) { throw new ArgumentNullException("Цена камеры должна быть больше 0", nameof(model.Price)); } - _logger.LogInformation("Manufacture. ManufactureName:{ManufactureName}.Cost:{ Cost}. Id: { Id}", model.ManufactureName, model.Price, model.Id); - var element = _ManufactureStorage.GetElement(new ManufactureSearchModel + _logger.LogInformation("Secure. SecureName:{SecureName}.Cost:{ Cost}. Id: { Id}", model.SecureName, model.Price, model.Id); + var element = _SecureStorage.GetElement(new SecureSearchModel { - ManufactureName = model.ManufactureName + SecureName = model.SecureName }); if (element != null && element.Id != model.Id) {