diff --git a/BlacksmithWorkshop/BlackmithWorkshopRestApi/Controllers/ImplementerController.cs b/BlacksmithWorkshop/BlackmithWorkshopRestApi/Controllers/ImplementerController.cs new file mode 100644 index 0000000..799dfaf --- /dev/null +++ b/BlacksmithWorkshop/BlackmithWorkshopRestApi/Controllers/ImplementerController.cs @@ -0,0 +1,112 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.Enums; +using Microsoft.AspNetCore.Mvc; + +namespace BlacksmithWorkshopRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ImplementerController : Controller + { + private readonly ILogger _logger; + + private readonly IOrderLogic _order; + + private readonly IImplementerLogic _logic; + + public ImplementerController(IOrderLogic order, IImplementerLogic logic, ILogger logger) + { + _logger = logger; + _order = order; + _logic = logic; + } + + [HttpGet] + public ImplementerViewModel? Login(string login, string password) + { + try + { + return _logic.ReadElement(new ImplementerSearchModel + { + ImplementerFIO = login, + Password = password + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка авторизации сотрудника"); + + throw; + } + } + + [HttpGet] + public List? GetNewOrders() + { + try + { + return _order.ReadList(new OrderSearchModel + { + Status = OrderStatus.Принят + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения новых заказов"); + + throw; + } + } + + [HttpGet] + public OrderViewModel? GetImplementerOrder(int implementerId) + { + try + { + return _order.ReadElement(new OrderSearchModel + { + ImplementerId = implementerId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения текущего заказа исполнителя"); + + throw; + } + } + + [HttpPost] + public void TakeOrderInWork(OrderBindingModel model) + { + try + { + _order.TakeOrderInWork(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка перевода заказа с №{Id} в работу", model.Id); + + throw; + } + } + + [HttpPost] + public void FinishOrder(OrderBindingModel model) + { + try + { + _order.FinishOrder(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа с №{ Id}", model.Id); + + throw; + } + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.Designer.cs new file mode 100644 index 0000000..62f0b8f --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.Designer.cs @@ -0,0 +1,162 @@ +namespace BlacksmithWorkshop +{ + partial class FormImplementer + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + labelFIO = new Label(); + labelPassword = new Label(); + labelWorkExperience = new Label(); + labelQualification = new Label(); + textBoxImplementerFIO = new TextBox(); + textBoxPassword = new TextBox(); + textBoxWorkExperience = new TextBox(); + textBoxQualification = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelFIO + // + labelFIO.AutoSize = true; + labelFIO.Location = new Point(38, 27); + labelFIO.Name = "labelFIO"; + labelFIO.Size = new Size(45, 20); + labelFIO.TabIndex = 0; + labelFIO.Text = "ФИО:"; + // + // labelPassword + // + labelPassword.AutoSize = true; + labelPassword.Location = new Point(38, 79); + labelPassword.Name = "labelPassword"; + labelPassword.Size = new Size(65, 20); + labelPassword.TabIndex = 1; + labelPassword.Text = "Пароль:"; + // + // labelWorkExperience + // + labelWorkExperience.AutoSize = true; + labelWorkExperience.Location = new Point(38, 136); + labelWorkExperience.Name = "labelWorkExperience"; + labelWorkExperience.Size = new Size(102, 20); + labelWorkExperience.TabIndex = 2; + labelWorkExperience.Text = "Стаж работы:"; + // + // labelQualification + // + labelQualification.AutoSize = true; + labelQualification.Location = new Point(319, 136); + labelQualification.Name = "labelQualification"; + labelQualification.Size = new Size(114, 20); + labelQualification.TabIndex = 3; + labelQualification.Text = "Квалификация:"; + // + // textBoxImplementerFIO + // + textBoxImplementerFIO.Location = new Point(160, 24); + textBoxImplementerFIO.Name = "textBoxImplementerFIO"; + textBoxImplementerFIO.Size = new Size(436, 27); + textBoxImplementerFIO.TabIndex = 4; + // + // textBoxPassword + // + textBoxPassword.Location = new Point(160, 76); + textBoxPassword.Name = "textBoxPassword"; + textBoxPassword.Size = new Size(436, 27); + textBoxPassword.TabIndex = 5; + // + // textBoxWorkExperience + // + textBoxWorkExperience.Location = new Point(160, 133); + textBoxWorkExperience.Name = "textBoxWorkExperience"; + textBoxWorkExperience.Size = new Size(126, 27); + textBoxWorkExperience.TabIndex = 6; + // + // textBoxQualification + // + textBoxQualification.Location = new Point(444, 133); + textBoxQualification.Name = "textBoxQualification"; + textBoxQualification.Size = new Size(152, 27); + textBoxQualification.TabIndex = 7; + // + // buttonSave + // + buttonSave.Location = new Point(387, 178); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(502, 178); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormImplementer + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(662, 224); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxQualification); + Controls.Add(textBoxWorkExperience); + Controls.Add(textBoxPassword); + Controls.Add(textBoxImplementerFIO); + Controls.Add(labelQualification); + Controls.Add(labelWorkExperience); + Controls.Add(labelPassword); + Controls.Add(labelFIO); + Name = "FormImplementer"; + Text = "Исполнитель"; + Load += FormImplementer_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelFIO; + private Label labelPassword; + private Label labelWorkExperience; + private Label labelQualification; + private TextBox textBoxImplementerFIO; + private TextBox textBoxPassword; + private TextBox textBoxWorkExperience; + private TextBox textBoxQualification; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.cs new file mode 100644 index 0000000..8df254d --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.cs @@ -0,0 +1,138 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.SearchModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BlacksmithWorkshop +{ + public partial class FormImplementer : Form + { + private readonly ILogger _logger; + + private readonly IImplementerLogic _logic; + + private int? _id; + + public int Id { set { _id = value; } } + + //конструктор + public FormImplementer(ILogger logger, IImplementerLogic logic) + { + InitializeComponent(); + + _logger = logger; + _logic = logic; + } + + //при загрузке формы + private void FormImplementer_Load(object sender, EventArgs e) + { + //проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение исполнителя"); + + var view = _logic.ReadElement(new ImplementerSearchModel { Id = _id.Value }); + + if (view != null) + { + textBoxImplementerFIO.Text = view.ImplementerFIO; + textBoxPassword.Text = view.Password; + textBoxWorkExperience.Text = view.WorkExperience.ToString(); + textBoxQualification.Text = view.Qualification.ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения исполнителя"); + + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + //проверка на заполнение поля с ФИО исполнителя + if (string.IsNullOrEmpty(textBoxImplementerFIO.Text)) + { + MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return; + } + + //проверка на заполнение поля с паролем + if (string.IsNullOrEmpty(textBoxPassword.Text)) + { + MessageBox.Show("Введите пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return; + } + + //проверка на заполнение поля со стажем + if (string.IsNullOrEmpty(textBoxWorkExperience.Text)) + { + MessageBox.Show("Введите ваш стаж", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return; + } + + //проверка на заполнение поля с квалификацией + if (string.IsNullOrEmpty(textBoxQualification.Text)) + { + MessageBox.Show("Введите свою квалификацию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return; + } + + _logger.LogInformation("Сохранение исполнителя"); + + try + { + var model = new ImplementerBindingModel + { + Id = _id ?? 0, + ImplementerFIO = textBoxImplementerFIO.Text, + Password = textBoxPassword.Text, + WorkExperience = Convert.ToInt16(textBoxWorkExperience.Text), + Qualification = Convert.ToInt16(textBoxQualification.Text) + }; + + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + + if (!operationResult) + { + throw new Exception("Ошибка при сохранеии. Дополнительная информация в логах."); + } + + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения исполнителя"); + + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.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/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.Designer.cs new file mode 100644 index 0000000..8aaf6d2 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.Designer.cs @@ -0,0 +1,114 @@ +namespace BlacksmithWorkshop +{ + partial class FormImplementers + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView = new DataGridView(); + buttonCreate = new Button(); + buttonChange = new Button(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 12); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(768, 426); + dataGridView.TabIndex = 0; + // + // buttonCreate + // + buttonCreate.Location = new Point(805, 22); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(160, 29); + buttonCreate.TabIndex = 1; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += ButtonCreate_Click; + // + // buttonChange + // + buttonChange.Location = new Point(805, 90); + buttonChange.Name = "buttonChange"; + buttonChange.Size = new Size(160, 29); + buttonChange.TabIndex = 2; + buttonChange.Text = "Изменить"; + buttonChange.UseVisualStyleBackColor = true; + buttonChange.Click += ButtonChange_Click; + // + // buttonDelete + // + buttonDelete.Location = new Point(805, 153); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(160, 29); + buttonDelete.TabIndex = 3; + buttonDelete.Text = "Удалить"; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.Location = new Point(805, 218); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(160, 29); + buttonUpdate.TabIndex = 4; + buttonUpdate.Text = "Обновить"; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpdate_Click; + // + // FormImplementers + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(991, 450); + Controls.Add(buttonUpdate); + Controls.Add(buttonDelete); + Controls.Add(buttonChange); + Controls.Add(buttonCreate); + Controls.Add(dataGridView); + Name = "FormImplementers"; + Text = "Исполнители"; + Load += FormImplementers_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Button buttonCreate; + private Button buttonChange; + private Button buttonDelete; + private Button buttonUpdate; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.cs new file mode 100644 index 0000000..9cc564e --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.cs @@ -0,0 +1,127 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BlacksmithWorkshop +{ + public partial class FormImplementers : Form + { + private readonly ILogger _logger; + + private readonly IImplementerLogic _logic; + + public FormImplementers(ILogger logger, IImplementerLogic logic) + { + InitializeComponent(); + + _logger = logger; + _logic = logic; + } + + private void FormImplementers_Load(object sender, EventArgs e) + { + LoadData(); + } + + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + + //растягиваем колонку Название на всю ширину, колонку Id скрываем + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + + _logger.LogInformation("Загрузка исполнителей"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки исполнителей"); + + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCreate_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); + + if (service is FormImplementer form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void ButtonChange_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); + + if (service is FormImplementer form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + + private void ButtonDelete_Click(object sender, EventArgs e) + { + //проверяем наличие выделенной строки + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + + _logger.LogInformation("Удаление исполнителя"); + + try + { + if (!_logic.Delete(new ImplementerBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления исполнителя"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + private void ButtonUpdate_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.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/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs index 55c2305..8e5792e 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -1,267 +1,286 @@ namespace BlacksmithWorkshop { - partial class FormMain - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } - #region Windows Form Designer generated code + #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - dataGridView = new DataGridView(); - buttonCreateOrder = new Button(); - buttonTakeOrderInWork = new Button(); - buttonOrderReady = new Button(); - buttonIssuedOrder = new Button(); - buttonRef = new Button(); - menuStrip = new MenuStrip(); - toolStripMenuItem = new ToolStripMenuItem(); - workPieceToolStripMenuItem = new ToolStripMenuItem(); - manufactureToolStripMenuItem = new ToolStripMenuItem(); - shopToolStripMenuItem = new ToolStripMenuItem(); - addManufactureToolStripMenuItem = new ToolStripMenuItem(); - reportToolStripMenuItem = new ToolStripMenuItem(); - groupedOrdersReportToolStripMenuItem = new ToolStripMenuItem(); - ordersReportToolStripMenuItem = new ToolStripMenuItem(); - workloadStoresReportToolStripMenuItem = new ToolStripMenuItem(); - shopsReportToolStripMenuItem = new ToolStripMenuItem(); - reportManufactureToolStripMenuItem = new ToolStripMenuItem(); - workPieceManufacturesToolStripMenuItem = new ToolStripMenuItem(); - buttonSellManufacture = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - menuStrip.SuspendLayout(); - SuspendLayout(); - // - // dataGridView - // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(11, 36); - dataGridView.Name = "dataGridView"; - dataGridView.RowHeadersWidth = 51; - dataGridView.RowTemplate.Height = 29; - dataGridView.Size = new Size(937, 448); - dataGridView.TabIndex = 0; - // - // buttonCreateOrder - // - buttonCreateOrder.Location = new Point(1014, 67); - buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(235, 29); - buttonCreateOrder.TabIndex = 1; - buttonCreateOrder.Text = "Создать заказ"; - buttonCreateOrder.UseVisualStyleBackColor = true; - buttonCreateOrder.Click += ButtonCreateOrder_Click; - // - // buttonTakeOrderInWork - // - buttonTakeOrderInWork.Location = new Point(1014, 143); - buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(235, 29); - buttonTakeOrderInWork.TabIndex = 2; - buttonTakeOrderInWork.Text = "Отдать на выполнение"; - buttonTakeOrderInWork.UseVisualStyleBackColor = true; - buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; - // - // buttonOrderReady - // - buttonOrderReady.Location = new Point(1014, 220); - buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(235, 29); - buttonOrderReady.TabIndex = 3; - buttonOrderReady.Text = "Заказ готов"; - buttonOrderReady.UseVisualStyleBackColor = true; - buttonOrderReady.Click += ButtonOrderReady_Click; - // - // buttonIssuedOrder - // - buttonIssuedOrder.Location = new Point(1014, 296); - buttonIssuedOrder.Name = "buttonIssuedOrder"; - buttonIssuedOrder.Size = new Size(235, 29); - buttonIssuedOrder.TabIndex = 4; - buttonIssuedOrder.Text = "Заказ выдан"; - buttonIssuedOrder.UseVisualStyleBackColor = true; - buttonIssuedOrder.Click += ButtonIssuedOrder_Click; - // - // buttonRef - // - buttonRef.Location = new Point(1014, 369); - buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(235, 29); - buttonRef.TabIndex = 5; - buttonRef.Text = "Обновить"; - buttonRef.UseVisualStyleBackColor = true; - buttonRef.Click += ButtonRef_Click; - // - // menuStrip - // - menuStrip.ImageScalingSize = new Size(20, 20); - menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, reportToolStripMenuItem }); - menuStrip.Location = new Point(0, 0); - menuStrip.Name = "menuStrip"; - menuStrip.Padding = new Padding(6, 3, 0, 3); - menuStrip.Size = new Size(1297, 30); - menuStrip.TabIndex = 6; - menuStrip.Text = "menuStrip1"; - // - // toolStripMenuItem - // - toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { workPieceToolStripMenuItem, manufactureToolStripMenuItem, shopToolStripMenuItem, addManufactureToolStripMenuItem }); - toolStripMenuItem.Name = "toolStripMenuItem"; - toolStripMenuItem.Size = new Size(117, 24); - toolStripMenuItem.Text = "Справочники"; - // - // workPieceToolStripMenuItem - // - workPieceToolStripMenuItem.Name = "workPieceToolStripMenuItem"; - workPieceToolStripMenuItem.Size = new Size(251, 26); - workPieceToolStripMenuItem.Text = "Заготовки"; - workPieceToolStripMenuItem.Click += WorkPieceToolStripMenuItem_Click; - // - // manufactureToolStripMenuItem - // - manufactureToolStripMenuItem.Name = "manufactureToolStripMenuItem"; - manufactureToolStripMenuItem.Size = new Size(251, 26); - manufactureToolStripMenuItem.Text = "Изделия"; - manufactureToolStripMenuItem.Click += ManufactureToolStripMenuItem_Click; - // - // shopToolStripMenuItem - // - shopToolStripMenuItem.Name = "shopToolStripMenuItem"; - shopToolStripMenuItem.Size = new Size(251, 26); - shopToolStripMenuItem.Text = "Магазины"; - shopToolStripMenuItem.Click += ShopToolStripMenuItem_Click; - // - // addManufactureToolStripMenuItem - // - addManufactureToolStripMenuItem.Name = "addManufactureToolStripMenuItem"; - addManufactureToolStripMenuItem.Size = new Size(251, 26); - addManufactureToolStripMenuItem.Text = "Пополнение магазина"; - addManufactureToolStripMenuItem.Click += AddManufactureToolStripMenuItem_Click; - // - // reportToolStripMenuItem - // - reportToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { groupedOrdersReportToolStripMenuItem, ordersReportToolStripMenuItem, workloadStoresReportToolStripMenuItem, shopsReportToolStripMenuItem, reportManufactureToolStripMenuItem, workPieceManufacturesToolStripMenuItem }); - reportToolStripMenuItem.Name = "reportToolStripMenuItem"; - reportToolStripMenuItem.Size = new Size(73, 24); - reportToolStripMenuItem.Text = "Отчёты"; - // - // groupedOrdersReportToolStripMenuItem - // - groupedOrdersReportToolStripMenuItem.Name = "groupedOrdersReportToolStripMenuItem"; - groupedOrdersReportToolStripMenuItem.Size = new Size(310, 26); - groupedOrdersReportToolStripMenuItem.Text = "Список заказов за весь период"; - groupedOrdersReportToolStripMenuItem.Click += GroupedOrdersReportToolStripMenuItem_Click; - // - // ordersReportToolStripMenuItem - // - ordersReportToolStripMenuItem.Name = "ordersReportToolStripMenuItem"; - ordersReportToolStripMenuItem.Size = new Size(310, 26); - ordersReportToolStripMenuItem.Text = "Список заказов"; - ordersReportToolStripMenuItem.Click += OrdersReportToolStripMenuItem_Click; - // - // workloadStoresReportToolStripMenuItem - // - workloadStoresReportToolStripMenuItem.Name = "workloadStoresReportToolStripMenuItem"; - workloadStoresReportToolStripMenuItem.Size = new Size(310, 26); - workloadStoresReportToolStripMenuItem.Text = "Загруженность магазинов"; - workloadStoresReportToolStripMenuItem.Click += WorkloadStoresReportToolStripMenuItem_Click; - // - // shopsReportToolStripMenuItem - // - shopsReportToolStripMenuItem.Name = "shopsReportToolStripMenuItem"; - shopsReportToolStripMenuItem.Size = new Size(310, 26); - shopsReportToolStripMenuItem.Text = "Таблица магазинов"; - shopsReportToolStripMenuItem.Click += ShopsReportToolStripMenuItem_Click; - // - // reportManufactureToolStripMenuItem - // - reportManufactureToolStripMenuItem.Name = "reportManufactureToolStripMenuItem"; - reportManufactureToolStripMenuItem.Size = new Size(310, 26); - reportManufactureToolStripMenuItem.Text = "Список изделий"; - reportManufactureToolStripMenuItem.Click += ReportManufactureToolStripMenuItem_Click; - // - // workPieceManufacturesToolStripMenuItem - // - workPieceManufacturesToolStripMenuItem.Name = "workPieceManufacturesToolStripMenuItem"; - workPieceManufacturesToolStripMenuItem.Size = new Size(310, 26); - workPieceManufacturesToolStripMenuItem.Text = "Заготовки по изделиям"; - workPieceManufacturesToolStripMenuItem.Click += WorkPieceManufacturesToolStripMenuItem_Click; - // - // buttonSellManufacture - // - buttonSellManufacture.Location = new Point(1014, 440); - buttonSellManufacture.Name = "buttonSellManufacture"; - buttonSellManufacture.Size = new Size(233, 29); - buttonSellManufacture.TabIndex = 7; - buttonSellManufacture.Text = "Продажа изделий"; - buttonSellManufacture.UseVisualStyleBackColor = true; - buttonSellManufacture.Click += ButtonSellManufacture_Click; - // - // FormMain - // - AutoScaleDimensions = new SizeF(8F, 20F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1297, 496); - Controls.Add(buttonSellManufacture); - Controls.Add(buttonRef); - Controls.Add(buttonIssuedOrder); - Controls.Add(buttonOrderReady); - Controls.Add(buttonTakeOrderInWork); - Controls.Add(buttonCreateOrder); - Controls.Add(dataGridView); - Controls.Add(menuStrip); - MainMenuStrip = menuStrip; - Name = "FormMain"; - Text = "Кузнечная мастерская"; - Load += FormMain_Load; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - menuStrip.ResumeLayout(false); - menuStrip.PerformLayout(); - ResumeLayout(false); - PerformLayout(); - } + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView = new DataGridView(); + buttonCreateOrder = new Button(); + buttonIssuedOrder = new Button(); + buttonRef = new Button(); + menuStrip = new MenuStrip(); + toolStripMenuItem = new ToolStripMenuItem(); + workPieceToolStripMenuItem = new ToolStripMenuItem(); + manufactureToolStripMenuItem = new ToolStripMenuItem(); + shopToolStripMenuItem = new ToolStripMenuItem(); + addManufactureToolStripMenuItem = new ToolStripMenuItem(); + reportToolStripMenuItem = new ToolStripMenuItem(); + groupedOrdersReportToolStripMenuItem = new ToolStripMenuItem(); + ordersReportToolStripMenuItem = new ToolStripMenuItem(); + workloadStoresReportToolStripMenuItem = new ToolStripMenuItem(); + shopsReportToolStripMenuItem = new ToolStripMenuItem(); + reportManufactureToolStripMenuItem = new ToolStripMenuItem(); + workPieceManufacturesToolStripMenuItem = new ToolStripMenuItem(); + workWithImplementerToolStripMenuItem = new ToolStripMenuItem(); + implementerToolStripMenuItem = new ToolStripMenuItem(); + работаСКлиентамиToolStripMenuItem = new ToolStripMenuItem(); + clientsToolStripMenuItem = new ToolStripMenuItem(); + startWorkToolStripMenuItem = new ToolStripMenuItem(); + buttonSellManufacture = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + menuStrip.SuspendLayout(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(11, 36); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(937, 448); + dataGridView.TabIndex = 0; + // + // buttonCreateOrder + // + buttonCreateOrder.Location = new Point(1014, 67); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(235, 29); + buttonCreateOrder.TabIndex = 1; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += ButtonCreateOrder_Click; + // + // buttonIssuedOrder + // + buttonIssuedOrder.Location = new Point(1014, 141); + buttonIssuedOrder.Name = "buttonIssuedOrder"; + buttonIssuedOrder.Size = new Size(235, 29); + buttonIssuedOrder.TabIndex = 4; + buttonIssuedOrder.Text = "Заказ выдан"; + buttonIssuedOrder.UseVisualStyleBackColor = true; + buttonIssuedOrder.Click += ButtonIssuedOrder_Click; + // + // buttonRef + // + buttonRef.Location = new Point(1014, 214); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(235, 29); + buttonRef.TabIndex = 5; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += ButtonRef_Click; + // + // menuStrip + // + menuStrip.ImageScalingSize = new Size(20, 20); + menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, reportToolStripMenuItem, workWithImplementerToolStripMenuItem, работаСКлиентамиToolStripMenuItem, startWorkToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Padding = new Padding(6, 3, 0, 3); + menuStrip.Size = new Size(1297, 30); + menuStrip.TabIndex = 6; + menuStrip.Text = "menuStrip1"; + // + // toolStripMenuItem + // + toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { workPieceToolStripMenuItem, manufactureToolStripMenuItem, shopToolStripMenuItem, addManufactureToolStripMenuItem }); + toolStripMenuItem.Name = "toolStripMenuItem"; + toolStripMenuItem.Size = new Size(117, 24); + toolStripMenuItem.Text = "Справочники"; + // + // workPieceToolStripMenuItem + // + workPieceToolStripMenuItem.Name = "workPieceToolStripMenuItem"; + workPieceToolStripMenuItem.Size = new Size(251, 26); + workPieceToolStripMenuItem.Text = "Заготовки"; + workPieceToolStripMenuItem.Click += WorkPieceToolStripMenuItem_Click; + // + // manufactureToolStripMenuItem + // + manufactureToolStripMenuItem.Name = "manufactureToolStripMenuItem"; + manufactureToolStripMenuItem.Size = new Size(251, 26); + manufactureToolStripMenuItem.Text = "Изделия"; + manufactureToolStripMenuItem.Click += ManufactureToolStripMenuItem_Click; + // + // shopToolStripMenuItem + // + shopToolStripMenuItem.Name = "shopToolStripMenuItem"; + shopToolStripMenuItem.Size = new Size(251, 26); + shopToolStripMenuItem.Text = "Магазины"; + shopToolStripMenuItem.Click += ShopToolStripMenuItem_Click; + // + // addManufactureToolStripMenuItem + // + addManufactureToolStripMenuItem.Name = "addManufactureToolStripMenuItem"; + addManufactureToolStripMenuItem.Size = new Size(251, 26); + addManufactureToolStripMenuItem.Text = "Пополнение магазина"; + addManufactureToolStripMenuItem.Click += AddManufactureToolStripMenuItem_Click; + // + // reportToolStripMenuItem + // + reportToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { groupedOrdersReportToolStripMenuItem, ordersReportToolStripMenuItem, workloadStoresReportToolStripMenuItem, shopsReportToolStripMenuItem, reportManufactureToolStripMenuItem, workPieceManufacturesToolStripMenuItem }); + reportToolStripMenuItem.Name = "reportToolStripMenuItem"; + reportToolStripMenuItem.Size = new Size(73, 24); + reportToolStripMenuItem.Text = "Отчёты"; + // + // groupedOrdersReportToolStripMenuItem + // + groupedOrdersReportToolStripMenuItem.Name = "groupedOrdersReportToolStripMenuItem"; + groupedOrdersReportToolStripMenuItem.Size = new Size(310, 26); + groupedOrdersReportToolStripMenuItem.Text = "Список заказов за весь период"; + groupedOrdersReportToolStripMenuItem.Click += GroupedOrdersReportToolStripMenuItem_Click; + // + // ordersReportToolStripMenuItem + // + ordersReportToolStripMenuItem.Name = "ordersReportToolStripMenuItem"; + ordersReportToolStripMenuItem.Size = new Size(310, 26); + ordersReportToolStripMenuItem.Text = "Список заказов"; + ordersReportToolStripMenuItem.Click += OrdersReportToolStripMenuItem_Click; + // + // workloadStoresReportToolStripMenuItem + // + workloadStoresReportToolStripMenuItem.Name = "workloadStoresReportToolStripMenuItem"; + workloadStoresReportToolStripMenuItem.Size = new Size(310, 26); + workloadStoresReportToolStripMenuItem.Text = "Загруженность магазинов"; + workloadStoresReportToolStripMenuItem.Click += WorkloadStoresReportToolStripMenuItem_Click; + // + // shopsReportToolStripMenuItem + // + shopsReportToolStripMenuItem.Name = "shopsReportToolStripMenuItem"; + shopsReportToolStripMenuItem.Size = new Size(310, 26); + shopsReportToolStripMenuItem.Text = "Таблица магазинов"; + shopsReportToolStripMenuItem.Click += ShopsReportToolStripMenuItem_Click; + // + // reportManufactureToolStripMenuItem + // + reportManufactureToolStripMenuItem.Name = "reportManufactureToolStripMenuItem"; + reportManufactureToolStripMenuItem.Size = new Size(310, 26); + reportManufactureToolStripMenuItem.Text = "Список изделий"; + reportManufactureToolStripMenuItem.Click += ReportManufactureToolStripMenuItem_Click; + // + // workPieceManufacturesToolStripMenuItem + // + workPieceManufacturesToolStripMenuItem.Name = "workPieceManufacturesToolStripMenuItem"; + workPieceManufacturesToolStripMenuItem.Size = new Size(310, 26); + workPieceManufacturesToolStripMenuItem.Text = "Заготовки по изделиям"; + workPieceManufacturesToolStripMenuItem.Click += WorkPieceManufacturesToolStripMenuItem_Click; + // + // workWithImplementerToolStripMenuItem + // + workWithImplementerToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { implementerToolStripMenuItem }); + workWithImplementerToolStripMenuItem.Name = "workWithImplementerToolStripMenuItem"; + workWithImplementerToolStripMenuItem.Size = new Size(196, 24); + workWithImplementerToolStripMenuItem.Text = "Работа с исполнителями"; + // + // implementerToolStripMenuItem + // + implementerToolStripMenuItem.Name = "implementerToolStripMenuItem"; + implementerToolStripMenuItem.Size = new Size(185, 26); + implementerToolStripMenuItem.Text = "Исполнители"; + implementerToolStripMenuItem.Click += ImplementerToolStripMenuItem_Click_1; + // + // работаСКлиентамиToolStripMenuItem + // + работаСКлиентамиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { clientsToolStripMenuItem }); + работаСКлиентамиToolStripMenuItem.Name = "работаСКлиентамиToolStripMenuItem"; + работаСКлиентамиToolStripMenuItem.Size = new Size(161, 24); + работаСКлиентамиToolStripMenuItem.Text = "Работа с клиентами"; + // + // clientsToolStripMenuItem + // + clientsToolStripMenuItem.Name = "clientsToolStripMenuItem"; + clientsToolStripMenuItem.Size = new Size(224, 26); + clientsToolStripMenuItem.Text = "Клиенты"; + clientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click_1; + // + // startWorkToolStripMenuItem + // + startWorkToolStripMenuItem.Name = "startWorkToolStripMenuItem"; + startWorkToolStripMenuItem.Size = new Size(114, 24); + startWorkToolStripMenuItem.Text = "Запуск работ"; + startWorkToolStripMenuItem.Click += StartWorkToolStripMenuItem_Click; + // + // buttonSellManufacture + // + buttonSellManufacture.Location = new Point(1014, 285); + buttonSellManufacture.Name = "buttonSellManufacture"; + buttonSellManufacture.Size = new Size(233, 29); + buttonSellManufacture.TabIndex = 7; + buttonSellManufacture.Text = "Продажа изделий"; + buttonSellManufacture.UseVisualStyleBackColor = true; + buttonSellManufacture.Click += ButtonSellManufacture_Click; + // + // FormMain + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1297, 496); + Controls.Add(buttonSellManufacture); + Controls.Add(buttonRef); + Controls.Add(buttonIssuedOrder); + Controls.Add(buttonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormMain"; + Text = "Кузнечная мастерская"; + Load += FormMain_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } - #endregion + #endregion - private DataGridView dataGridView; - private Button buttonCreateOrder; - private Button buttonTakeOrderInWork; - private Button buttonOrderReady; - private Button buttonIssuedOrder; - private Button buttonRef; - private MenuStrip menuStrip; - private ToolStripMenuItem toolStripMenuItem; - private ToolStripMenuItem workPieceToolStripMenuItem; - private ToolStripMenuItem manufactureToolStripMenuItem; - private ToolStripMenuItem shopToolStripMenuItem; - private ToolStripMenuItem addManufactureToolStripMenuItem; - private Button buttonSellManufacture; - private ToolStripMenuItem reportToolStripMenuItem; - private ToolStripMenuItem groupedOrdersReportToolStripMenuItem; - private ToolStripMenuItem ordersReportToolStripMenuItem; - private ToolStripMenuItem workloadStoresReportToolStripMenuItem; - private ToolStripMenuItem shopsReportToolStripMenuItem; - private ToolStripMenuItem reportManufactureToolStripMenuItem; - private ToolStripMenuItem workPieceManufacturesToolStripMenuItem; - } + private DataGridView dataGridView; + private Button buttonCreateOrder; + private Button buttonIssuedOrder; + private Button buttonRef; + private MenuStrip menuStrip; + private ToolStripMenuItem toolStripMenuItem; + private ToolStripMenuItem workPieceToolStripMenuItem; + private ToolStripMenuItem manufactureToolStripMenuItem; + private ToolStripMenuItem shopToolStripMenuItem; + private ToolStripMenuItem addManufactureToolStripMenuItem; + private Button buttonSellManufacture; + private ToolStripMenuItem reportToolStripMenuItem; + private ToolStripMenuItem groupedOrdersReportToolStripMenuItem; + private ToolStripMenuItem ordersReportToolStripMenuItem; + private ToolStripMenuItem workloadStoresReportToolStripMenuItem; + private ToolStripMenuItem shopsReportToolStripMenuItem; + private ToolStripMenuItem reportManufactureToolStripMenuItem; + private ToolStripMenuItem workPieceManufacturesToolStripMenuItem; + private ToolStripMenuItem workWithImplementerToolStripMenuItem; + private ToolStripMenuItem implementerToolStripMenuItem; + private ToolStripMenuItem работаСКлиентамиToolStripMenuItem; + private ToolStripMenuItem clientsToolStripMenuItem; + private ToolStripMenuItem startWorkToolStripMenuItem; + } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs index ebdb521..6f379a7 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -15,161 +15,111 @@ using System.Windows.Forms; namespace BlacksmithWorkshop { - public partial class FormMain : Form - { - private readonly ILogger _logger; + public partial class FormMain : Form + { + private readonly ILogger _logger; - private readonly IOrderLogic _orderLogic; + private readonly IOrderLogic _orderLogic; - private readonly IReportLogic _reportLogic; + private readonly IReportLogic _reportLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) - { - InitializeComponent(); + private readonly IWorkProcess _workProcess; - _logger = logger; - _orderLogic = orderLogic; - _reportLogic = reportLogic; - } + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess) + { + InitializeComponent(); - private void FormMain_Load(object sender, EventArgs e) - { - LoadData(); - } + _logger = logger; + _orderLogic = orderLogic; + _reportLogic = reportLogic; + _workProcess = workProcess; + } - private void LoadData() - { - _logger.LogInformation("Загрузка заказов"); + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } - try - { - var list = _orderLogic.ReadList(null); + private void LoadData() + { + _logger.LogInformation("Загрузка заказов"); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["ManufactureId"].Visible = false; - } + try + { + var list = _orderLogic.ReadList(null); - _logger.LogInformation("Загрузка заказов"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки заказов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["ManufactureId"].Visible = false; + dataGridView.Columns["ImplementerId"].Visible = false; + dataGridView.Columns["ClientId"].Visible = false; + dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } - private void WorkPieceToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormWorkPieces)); + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } - if (service is FormWorkPieces form) - { - form.ShowDialog(); - } - } + private void WorkPieceToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormWorkPieces)); - private void ManufactureToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormManufactures)); + if (service is FormWorkPieces form) + { + form.ShowDialog(); + } + } - if (service is FormManufactures form) - { - form.ShowDialog(); - } - } + private void ManufactureToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormManufactures)); - private void ButtonCreateOrder_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormManufactures form) + { + form.ShowDialog(); + } + } - if (service is FormCreateOrder form) - { - form.ShowDialog(); - LoadData(); - } + private void ButtonCreateOrder_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); - } + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } - private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + } - try - { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel - { - Id = id - }); + private void ButtonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } + try + { + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel + { + Id = id + }); - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } - private void ButtonOrderReady_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); - - try - { - var operationResult = _orderLogic.FinishOrder(new OrderBindingModel - { - Id = id - }); - - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о готовности заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - - private void ButtonIssuedOrder_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); - - try - { - var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel - { - Id = id - }); - - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - - _logger.LogInformation("Заказ №{id} выдан", id); + _logger.LogInformation("Заказ №{id} выдан", id); LoadData(); } @@ -181,106 +131,133 @@ namespace BlacksmithWorkshop } } - private void ButtonRef_Click(object sender, EventArgs e) - { - LoadData(); - } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } - private void ButtonSellManufacture_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormSellManufacture)); - if (service is FormSellManufacture form) - { - form.ShowDialog(); - LoadData(); - } - } + private void ButtonSellManufacture_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSellManufacture)); + if (service is FormSellManufacture form) + { + form.ShowDialog(); + LoadData(); + } + } - private void ShopToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + private void ShopToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); - if (service is FormShops form) - { - form.ShowDialog(); - } - } + if (service is FormShops form) + { + form.ShowDialog(); + } + } - private void AddManufactureToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormAddManufacture)); + private void AddManufactureToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormAddManufacture)); - if (service is FormAddManufacture form) - { - form.ShowDialog(); - LoadData(); - } - } + if (service is FormAddManufacture form) + { + form.ShowDialog(); + LoadData(); + } + } - private void GroupedOrdersReportToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupedOrders)); + private void GroupedOrdersReportToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupedOrders)); - if (service is FormReportGroupedOrders form) - { - form.ShowDialog(); - } - } + if (service is FormReportGroupedOrders form) + { + form.ShowDialog(); + } + } - private void OrdersReportToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + private void WorkloadStoresReportToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportShopManufactures)); - if (service is FormReportOrders form) - { - form.ShowDialog(); - } - } + if (service is FormReportShopManufactures form) + { + form.ShowDialog(); + } + } - private void WorkloadStoresReportToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportShopManufactures)); + private void ShopsReportToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; - if (service is FormReportShopManufactures form) - { - form.ShowDialog(); - } - } + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveShopsToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } - private void ShopsReportToolStripMenuItem_Click(object sender, EventArgs e) - { - using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + private void WorkPieceManufacturesToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportManufactureWorkPieces)); - if (dialog.ShowDialog() == DialogResult.OK) - { - _reportLogic.SaveShopsToWordFile(new ReportBindingModel { FileName = dialog.FileName }); - MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } + if (service is FormReportManufactureWorkPieces form) + { + form.ShowDialog(); + } + } - private void ReportManufactureToolStripMenuItem_Click(object sender, EventArgs e) - { - using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + private void ImplementerToolStripMenuItem_Click_1(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormImplementers)); - if (dialog.ShowDialog() == DialogResult.OK) - { - _reportLogic.SaveManufacturesToWordFile(new ReportBindingModel - { - FileName = dialog.FileName - }); + if (service is FormImplementers form) + { + form.ShowDialog(); + } + } - MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } + private void ClientsToolStripMenuItem_Click_1(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormClients)); - private void WorkPieceManufacturesToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportManufactureWorkPieces)); + if (service is FormClients form) + { + form.ShowDialog(); + } + } - if (service is FormReportManufactureWorkPieces form) - { - form.ShowDialog(); - } - } - } + private void StartWorkToolStripMenuItem_Click(object sender, EventArgs e) + { + _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic); + + MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + + private void ReportManufactureToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveManufacturesToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void OrdersReportToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } + } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs index 8f7e25c..4313c32 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs @@ -43,14 +43,20 @@ namespace BlacksmithWorkshop 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(); @@ -69,6 +75,9 @@ namespace BlacksmithWorkshop services.AddTransient(); services.AddTransient(); services.AddTransient(); - } + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + } } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ClientLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ClientLogic.cs index 7a58bac..110b3db 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ClientLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ClientLogic.cs @@ -141,7 +141,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic throw new ArgumentNullException("Отсутствие пароля в учётной записи", nameof(model.Password)); } - _logger.LogInformation("WorkPiece. ClientFIO:{ClientFIO}. Email:{Email}. Password:{Password}. Id:{Id}", + _logger.LogInformation("Client. ClientFIO:{ClientFIO}. Email:{Email}. Password:{Password}. Id:{Id}", model.ClientFIO, model.Email, model.Password, model.Id); //для проверка на наличие такого же аккаунта diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ImplementerLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ImplementerLogic.cs new file mode 100644 index 0000000..b9ade18 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ImplementerLogic.cs @@ -0,0 +1,167 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.StoragesContracts; +using BlacksmithWorkshopContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopBusinessLogic.BusinessLogic +{ + public class ImplementerLogic : IImplementerLogic + { + private readonly ILogger _logger; + + private readonly IImplementerStorage _implementerStorage; + + public ImplementerLogic(ILogger logger, IImplementerStorage implementerStorage) + { + _logger = logger; + _implementerStorage = implementerStorage; + } + + public List? ReadList(ImplementerSearchModel? model) + { + _logger.LogInformation("ReadList. ImplementerFIO:{ImplementerFIO}. Id:{Id}", model?.ImplementerFIO, model?.Id); + + //list хранит весь список в случае, если model пришло со значением null на вход метода + var list = model == null ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + + return list; + } + + public ImplementerViewModel? ReadElement(ImplementerSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadList. ImplementerFIO:{ImplementerFIO}. Id:{Id}", model.ImplementerFIO, model?.Id); + + var element = _implementerStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + + return null; + } + + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + + return element; + } + + public bool Create(ImplementerBindingModel model) + { + CheckModel(model); + + if (_implementerStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + + return false; + } + + return true; + } + + public bool Update(ImplementerBindingModel model) + { + CheckModel(model); + + if (_implementerStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + + return false; + } + + return true; + } + + public bool Delete(ImplementerBindingModel model) + { + CheckModel(model, false); + + _logger.LogInformation("Delete. Id:{Id}", model.Id); + + if (_implementerStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + + return false; + } + + return true; + } + + //проверка входного аргумента для методов Insert, Update и Delete + private void CheckModel(ImplementerBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + //так как при удалении передаём как параметр false + if (!withParams) + { + return; + } + + //проверка на наличие ФИО + if (string.IsNullOrEmpty(model.ImplementerFIO)) + { + throw new ArgumentNullException("Отсутствие ФИО в учётной записи", nameof(model.ImplementerFIO)); + } + + //проверка на наличие пароля + if (string.IsNullOrEmpty(model.Password)) + { + throw new ArgumentNullException("Отсутствие пароля в учётной записи", nameof(model.Password)); + } + + //проверка на наличие квалификации + if (model.Qualification <= 0) + { + throw new ArgumentNullException("Указана некорректная квалификация", nameof(model.Qualification)); + } + + //проверка на наличие квалификации + if (model.WorkExperience < 0) + { + throw new ArgumentNullException("Указан некоректный стаж работы", nameof(model.WorkExperience)); + } + + _logger.LogInformation("Implementer. ImplementerFIO:{ImplementerFIO}. Password:{Password}. " + + "Qualification:{Qualification}. WorkExperience:{ WorkExperience}. Id:{Id}", + model.ImplementerFIO, model.Password, model.Qualification, model.WorkExperience, model.Id); + + //для проверка на наличие такого же аккаунта + var element = _implementerStorage.GetElement(new ImplementerSearchModel + { + ImplementerFIO = model.ImplementerFIO, + }); + + //если элемент найден и его Id не совпадает с Id переданного объекта + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Исполнитель с таким именем уже есть"); + } + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/OrderLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/OrderLogic.cs index 983807e..2aad47e 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/OrderLogic.cs @@ -40,7 +40,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic //list хранит весь список в случае, если model пришло со значением null на вход метода var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); - if(list == null) + if (list == null) { _logger.LogWarning("ReadList return null list"); @@ -52,8 +52,31 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic return list; } - //создание чека - public bool CreateOrder(OrderBindingModel model) + public OrderViewModel? ReadElement(OrderSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. Id:{Id}", model?.Id); + + var element = _orderStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + + return null; + } + + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + + return element; + } + + //создание чека + public bool CreateOrder(OrderBindingModel model) { CheckModel(model); @@ -67,8 +90,8 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic if(_orderStorage.Insert(model) == null) { - model.Status = OrderStatus.Неизвестен; _logger.LogWarning("Insert operation failed"); + return false; } @@ -148,7 +171,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic } //проверка на возможность обновления статуса на следующий - if (viewModel.Status + 1 != newOrderStatus) + if (viewModel.Status + 1 != newOrderStatus && viewModel.Status != OrderStatus.Ожидание) { _logger.LogWarning("Status update operation failed. New status " + newOrderStatus.ToString() + " incorrect"); return false; @@ -156,11 +179,15 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic model.Status = newOrderStatus; - //проверка на выдачу - if (model.Status == OrderStatus.Готов) + //не забываем положить id работника + if (viewModel.ImplementerId.HasValue) { - model.DateImplement = DateTime.Now; - + model.ImplementerId = viewModel.ImplementerId; + } + + //проверка на выдачу + if (model.Status == OrderStatus.Готов || viewModel.Status == OrderStatus.Ожидание) + { var manufacture = _manufactureStorage.GetElement(new() { Id = viewModel.ManufactureId }); if (manufacture == null) @@ -170,7 +197,13 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic if (!_shopLogic.AddManufactures(manufacture, viewModel.Count)) { - throw new Exception($"AddManufactures operation failed. Shop is full."); + model.Status = OrderStatus.Ожидание; + + _logger.LogWarning($"AddManufactures operation failed. Shop is full."); + } + else + { + model.DateImplement = DateTime.Now; } } else @@ -183,8 +216,6 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic //финальная проверка на возможность обновления if (_orderStorage.Update(model) == null) { - model.Status--; - _logger.LogWarning("Update operation failed"); return false; @@ -192,5 +223,5 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic return true; } - } + } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ShopLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ShopLogic.cs index b86e500..7c9e389 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ShopLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ShopLogic.cs @@ -78,6 +78,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic } _logger.LogInformation("AddManufacture. ShopName:{ShopName}. Id: {Id}", model?.ShopName, model?.Id); + var shop = _shopStorage.GetElement(model); if (shop == null) @@ -214,25 +215,20 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic { if (!AddManufacture(new() { Id = shop.Id }, model, shop.MaxCountManufactures - shop.ShopManufactures.Select(x => x.Value.Item2).Sum())) { - _logger.LogWarning("AddManufactures operation failed."); - + _logger.LogWarning("AddIceCreams operation failed."); return false; } - count -= shop.MaxCountManufactures - shop.ShopManufactures.Select(x => x.Value.Item2).Sum(); } else { if (!AddManufacture(new() { Id = shop.Id }, model, count)) { - _logger.LogWarning("AddManufactures operation failed."); - + _logger.LogWarning("AddIceCreams operation failed."); return false; } - count -= count; } - if (count == 0) { return true; diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/WorkModeling.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/WorkModeling.cs new file mode 100644 index 0000000..cf3419a --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/WorkModeling.cs @@ -0,0 +1,196 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.Enums; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopBusinessLogic.BusinessLogic +{ + public class WorkModeling : IWorkProcess + { + private readonly ILogger _logger; + + private readonly Random _rnd; + + private IOrderLogic? _orderLogic; + + public WorkModeling(ILogger logger) + { + _logger = logger; + _rnd = new Random(1000); + } + + public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic) + { + _orderLogic = orderLogic; + var implementers = implementerLogic.ReadList(null); + + if (implementers == null) + { + _logger.LogWarning("DoWork. Implementers is null"); + return; + } + + var orders = _orderLogic.ReadList(new() { Status = OrderStatus.Принят }); + if (orders == null) + { + _logger.LogWarning("DoWork. Orders is null or empty"); + return; + } + + _logger.LogDebug("DoWork for {Count} orders", orders.Count); + + foreach (var implementer in implementers) + { + Task.Run(() => WorkerWorkAsync(implementer, orders)); + } + } + + // Иммитация работы исполнителя + private async Task WorkerWorkAsync(ImplementerViewModel implementer, List orders) + { + if (_orderLogic == null || implementer == null) + { + return; + } + + await Task.Run(() => + { + try + { + var runOrder = _orderLogic.ReadList(new OrderSearchModel + { + ImplementerId = implementer.Id, + Status = OrderStatus.Ожидание + }); + + if (runOrder == null) + { + return; + } + + foreach(var order in runOrder) + { + _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id); + _orderLogic.FinishOrder(new OrderBindingModel + { + Id = order.Id + }); + // отдыхаем + //Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); + } + } + // заказа может не быть, просто игнорируем ошибку + catch (InvalidOperationException ex) + { + _logger.LogWarning(ex, "Error try get work"); + } + // а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации + catch (Exception ex) + { + _logger.LogError(ex, "Error while do work"); + throw; + } + }); + + await RunOrderInWork(implementer); + + await Task.Run(() => + { + foreach (var order in orders) + { + try + { + _logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id); + + // пытаемся назначить заказ на исполнителя + _orderLogic.TakeOrderInWork(new OrderBindingModel + { + Id = order.Id, + ImplementerId = implementer.Id + }); + + // делаем работу + Thread.Sleep(implementer.WorkExperience * order.Count); + + _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id); + + _orderLogic.FinishOrder(new OrderBindingModel + { + Id = order.Id, + }); + + // отдыхаем + Thread.Sleep(implementer.Qualification); + } + // кто-то мог уже перехватить заказ, игнорируем ошибку + catch (InvalidOperationException ex) + { + _logger.LogWarning(ex, "Error try get work"); + } + // заканчиваем выполнение имитации в случае иной ошибки + catch (Exception ex) + { + _logger.LogError(ex, "Error while do work"); + throw; + } + } + }); + } + + //Ищем заказ, которые уже в работе (вдруг исполнителя прервали) + private async Task RunOrderInWork(ImplementerViewModel implementer) + { + if (_orderLogic == null || implementer == null) + { + return; + } + + try + { + var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel + { + ImplementerId = implementer.Id, + Status = OrderStatus.Выполняется + })); + + if (runOrder == null) + { + return; + } + + _logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id); + + // доделываем работу + Thread.Sleep(implementer.WorkExperience * runOrder.Count); + + _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id); + + _orderLogic.FinishOrder(new OrderBindingModel + { + Id = runOrder.Id + }); + + // отдыхаем + Thread.Sleep(implementer.Qualification); + } + // заказа может не быть, просто игнорируем ошибку + catch (InvalidOperationException ex) + { + _logger.LogWarning(ex, "Error try get work"); + } + // а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации + catch (Exception ex) + { + _logger.LogError(ex, "Error while do work"); + throw; + } + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ImplementerBindingModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ImplementerBindingModel.cs new file mode 100644 index 0000000..e26ac44 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ImplementerBindingModel.cs @@ -0,0 +1,22 @@ +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.BindingModels +{ + public class ImplementerBindingModel : IImplementerModel + { + public int Id { get; set; } + + public string ImplementerFIO { get; set; } = string.Empty; + + public string Password { get; set; } = string.Empty; + + public int WorkExperience { get; set; } + + public int Qualification { get; set; } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/OrderBindingModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/OrderBindingModel.cs index f0075de..a279855 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/OrderBindingModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/OrderBindingModel.cs @@ -15,7 +15,9 @@ namespace BlacksmithWorkshopContracts.BindingModels public int ClientId { get; set; } - public int ManufactureId { get; set; } + public int? ImplementerId { get; set; } + + public int ManufactureId { get; set; } public int Count { get; set; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IImplementerLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IImplementerLogic.cs new file mode 100644 index 0000000..112931c --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IImplementerLogic.cs @@ -0,0 +1,24 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.BusinessLogicsContracts +{ + public interface IImplementerLogic + { + List? ReadList(ImplementerSearchModel? model); + + ImplementerViewModel? ReadElement(ImplementerSearchModel model); + + bool Create(ImplementerBindingModel model); + + bool Update(ImplementerBindingModel model); + + bool Delete(ImplementerBindingModel model); + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IOrderLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IOrderLogic.cs index 204cc77..f439042 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IOrderLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -14,7 +14,9 @@ namespace BlacksmithWorkshopContracts.BusinessLogicsContracts { List? ReadList(OrderSearchModel? model); - bool CreateOrder(OrderBindingModel model); + OrderViewModel? ReadElement(OrderSearchModel model); + + bool CreateOrder(OrderBindingModel model); bool TakeOrderInWork(OrderBindingModel model); diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IWorkProcess.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IWorkProcess.cs new file mode 100644 index 0000000..812fdaf --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IWorkProcess.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.BusinessLogicsContracts +{ + //интерфейс для класса, имитирующего работу + public interface IWorkProcess + { + // Запуск работ + void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic); + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ImplementerSearchModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ImplementerSearchModel.cs new file mode 100644 index 0000000..864d8f2 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ImplementerSearchModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.SearchModels +{ + public class ImplementerSearchModel + { + public int? Id { get; set; } + + public string? ImplementerFIO { get; set; } + + public string? Password { get; set; } + + public int? WorkExperience { get; set; } + + public int? Qualification { get; set; } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/OrderSearchModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/OrderSearchModel.cs index b949370..3337e2e 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/OrderSearchModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/OrderSearchModel.cs @@ -1,4 +1,5 @@ -using System; +using BlacksmithWorkshopDataModels.Enums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -15,10 +16,14 @@ namespace BlacksmithWorkshopContracts.SearchModels //для поиска по клиенту public int? ClientId { get; set; } + //для поиска по исполнителю + public int? ImplementerId { get; set; } + //два поля для возможности производить выборку public DateTime? DateFrom { get; set; } - public DateTime? DateTo { get; set; } - } + public DateTime? DateTo { get; set; } + public OrderStatus? Status { get; set; } + } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ShopSearchModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ShopSearchModel.cs index 18e9323..9e1f2ab 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ShopSearchModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/SearchModels/ShopSearchModel.cs @@ -1,4 +1,5 @@ -using System; +using BlacksmithWorkshopDataModels.Enums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IImplementerStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IImplementerStorage.cs new file mode 100644 index 0000000..8f580d3 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IImplementerStorage.cs @@ -0,0 +1,26 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.StoragesContracts +{ + public interface IImplementerStorage + { + List GetFullList(); + + List GetFilteredList(ImplementerSearchModel model); + + ImplementerViewModel? GetElement(ImplementerSearchModel model); + + ImplementerViewModel? Insert(ImplementerBindingModel model); + + ImplementerViewModel? Update(ImplementerBindingModel model); + + ImplementerViewModel? Delete(ImplementerBindingModel model); + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ImplementerViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ImplementerViewModel.cs new file mode 100644 index 0000000..2554098 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ImplementerViewModel.cs @@ -0,0 +1,27 @@ +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopContracts.ViewModels +{ + public class ImplementerViewModel : IImplementerModel + { + public int Id { get; set; } + + [DisplayName("ФИО исполнителя")] + public string ImplementerFIO { get; set; } = string.Empty; + + [DisplayName("Пароль")] + public string Password { get; set; } = string.Empty; + + [DisplayName("Стаж")] + public int WorkExperience { get; set; } + + [DisplayName("Квалификация")] + public int Qualification { get; set; } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs index aabfa1b..b550429 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs @@ -17,6 +17,8 @@ namespace BlacksmithWorkshopContracts.ViewModels public int ClientId { get; set; } + public int? ImplementerId { get; set; } + public int ManufactureId { get; set; } [DisplayName("ФИО клиента")] @@ -25,7 +27,10 @@ namespace BlacksmithWorkshopContracts.ViewModels [DisplayName("Изделие")] public string ManufactureName { get; set; } = string.Empty; - [DisplayName("Количество")] + [DisplayName("ФИО исполнителя")] + public string ImplementerFIO { get; set; } = string.Empty; + + [DisplayName("Количество")] public int Count { get; set; } [DisplayName("Сумма")] diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Enums/OrderStatus.cs b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Enums/OrderStatus.cs index 293d304..8e74b66 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Enums/OrderStatus.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Enums/OrderStatus.cs @@ -17,6 +17,8 @@ namespace BlacksmithWorkshopDataModels.Enums Готов = 2, - Выдан = 3 + Выдан = 3, + + Ожидание = 4 } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IImplementerModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IImplementerModel.cs new file mode 100644 index 0000000..9ac63d5 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IImplementerModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopDataModels.Models +{ + //модель исполнителя + public interface IImplementerModel : IId + { + string ImplementerFIO { get; } + + string Password { get; } + + int WorkExperience { get; } + + int Qualification { get; } + } + +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IOrderModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IOrderModel.cs index a7de5a6..ba64ce0 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IOrderModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IOrderModel.cs @@ -16,8 +16,11 @@ namespace BlacksmithWorkshopDataModels.Models //id клиента int ClientId { get; } - //кол-во продуктов - int Count { get; } + //id исполнителя + int? ImplementerId { get; } + + //кол-во продуктов + int Count { get; } //суммарная стоимость продуктов double Sum { get; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDatabase.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDatabase.cs index de33998..9081cb6 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDatabase.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDatabase.cs @@ -34,5 +34,7 @@ namespace BlacksmithWorkshopDatabaseImplement public virtual DbSet ShopManufactures { get; set; } public virtual DbSet Clients { get; set; } - } + + public virtual DbSet Implementers { set; get; } + } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/ImplementerStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/ImplementerStorage.cs new file mode 100644 index 0000000..7ddca5e --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/ImplementerStorage.cs @@ -0,0 +1,128 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.StoragesContracts; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDatabaseImplement.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopDatabaseImplement.Implements +{ + public class ImplementerStorage : IImplementerStorage + { + public List GetFullList() + { + using var context = new BlacksmithWorkshopDatabase(); + + return context.Implementers + .Include(x => x.Orders) + .Select(x => x.GetViewModel) + .ToList(); + } + public List GetFilteredList(ImplementerSearchModel model) + { + if (string.IsNullOrEmpty(model.ImplementerFIO)) + { + return new(); + } + + using var context = new BlacksmithWorkshopDatabase(); + + return context.Implementers + .Include(x => x.Orders) + .Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO)) + .Select(x => x.GetViewModel) + .ToList(); + } + + public ImplementerViewModel? GetElement(ImplementerSearchModel model) + { + using var context = new BlacksmithWorkshopDatabase(); + + if (model.Id.HasValue) + { + return context.Implementers + .Include(x => x.Orders) + .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) + ?.GetViewModel; + } + else if (!string.IsNullOrEmpty(model.ImplementerFIO) && !string.IsNullOrEmpty(model.Password)) + { + return context.Implementers + .Include(x => x.Orders) + .FirstOrDefault(x => (x.ImplementerFIO == model.ImplementerFIO && x.Password == model.Password)) + ?.GetViewModel; + } + + return new(); + } + + public ImplementerViewModel? Insert(ImplementerBindingModel model) + { + var newImplementer = Implementer.Create(model); + + if (newImplementer == null) + { + return null; + } + + using var context = new BlacksmithWorkshopDatabase(); + + context.Implementers.Add(newImplementer); + context.SaveChanges(); + + return context.Implementers + .Include(x => x.Orders) + .FirstOrDefault(x => x.Id == newImplementer.Id) + ?.GetViewModel; + } + + public ImplementerViewModel? Update(ImplementerBindingModel model) + { + using var context = new BlacksmithWorkshopDatabase(); + var order = context.Implementers + .Include(x => x.Orders) + .FirstOrDefault(x => x.Id == model.Id); + + if (order == null) + { + return null; + } + + order.Update(model); + context.SaveChanges(); + + return context.Implementers + .Include(x => x.Orders) + .FirstOrDefault(x => x.Id == model.Id) + ?.GetViewModel; + } + public ImplementerViewModel? Delete(ImplementerBindingModel model) + { + using var context = new BlacksmithWorkshopDatabase(); + + var element = context.Implementers + .FirstOrDefault(rec => rec.Id == model.Id); + + if (element != null) + { + // для отображения КОРРЕКТНОЙ ViewModel-и + var deletedElement = context.Implementers + .Include(x => x.Orders) + .FirstOrDefault(x => x.Id == model.Id) + ?.GetViewModel; + + context.Implementers.Remove(element); + context.SaveChanges(); + + return deletedElement; + } + + return null; + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs index 2b54fc3..ffab329 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs @@ -42,17 +42,34 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements public OrderViewModel? GetElement(OrderSearchModel model) { + using var context = new BlacksmithWorkshopDatabase(); + if (model.ImplementerId.HasValue && model.Status.HasValue) + { + return context.Orders + .Include(x => x.Manufacture) + .Include(x => x.Client) + .Include(x => x.Implementer) + .FirstOrDefault(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status) + ?.GetViewModel; + } + if (model.ImplementerId.HasValue) + { + return context.Orders + .Include(x => x.Manufacture) + .Include(x => x.Client) + .Include(x => x.Implementer) + .FirstOrDefault(x => x.ImplementerId == model.ImplementerId) + ?.GetViewModel; + } if (!model.Id.HasValue) { return null; } - - using var context = new BlacksmithWorkshopDatabase(); - return context.Orders .Include(x => x.Manufacture) - .Include(x => x.Client) - .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) + .Include(x => x.Client) + .Include(x => x.Implementer) + .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) ?.GetViewModel; } @@ -65,7 +82,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements return context.Orders .Include(x => x.Manufacture) .Include(x => x.Client) - .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) + .Include(x => x.Implementer) + .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) .Select(x => x.GetViewModel) .ToList(); } @@ -74,7 +92,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements return context.Orders .Include(x => x.Manufacture) .Include(x => x.Client) - .Where(x => x.Id == model.Id) + .Include(x => x.Implementer) + .Where(x => x.Id == model.Id) .Select(x => x.GetViewModel) .ToList(); } @@ -83,12 +102,29 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements return context.Orders .Include(x => x.Manufacture) .Include(x => x.Client) + .Include(x => x.Implementer) .Where(x => x.ClientId == model.ClientId) .Select(x => x.GetViewModel) .ToList(); } + else if (model.ImplementerId.HasValue) + { + return context.Orders + .Include(x => x.Manufacture) + .Include(x => x.Client) + .Include(x => x.Implementer) + .Where(x => x.ImplementerId == model.ImplementerId) + .Select(x => x.GetViewModel) + .ToList(); + } - return new(); + return context.Orders + .Include(x => x.Manufacture) + .Include(x => x.Client) + .Include(x => x.Implementer) + .Where(x => model.Status == x.Status) + .Select(x => x.GetViewModel) + .ToList(); } public List GetFullList() @@ -98,6 +134,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements return context.Orders .Include(x => x.Manufacture) .Include(x => x.Client) + .Include(x => x.Implementer) .Select(x => x.GetViewModel) .ToList(); } @@ -126,10 +163,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements public OrderViewModel? Update(OrderBindingModel model) { using var context = new BlacksmithWorkshopDatabase(); - var order = context.Orders - .Include(x => x.Manufacture) - .Include(x => x.Client) - .FirstOrDefault(x => x.Id == model.Id); + + var order = context.Orders.FirstOrDefault(x => x.Id == model.Id); if (order == null) { @@ -142,6 +177,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements return context.Orders .Include(x => x.Manufacture) .Include(x => x.Client) + .Include(x => x.Implementer) .FirstOrDefault(x => x.Id == model.Id) ?.GetViewModel; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405071103_SixLab.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405071103_SixLab.Designer.cs new file mode 100644 index 0000000..0a7e0c9 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405071103_SixLab.Designer.cs @@ -0,0 +1,259 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230405071103_SixLab")] + partial class SixLab + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405071103_SixLab.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405071103_SixLab.cs new file mode 100644 index 0000000..abd4096 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405071103_SixLab.cs @@ -0,0 +1,71 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class SixLab : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE FROM [dbo].[Orders]"); + + migrationBuilder.AddColumn( + name: "ImplementerId", + table: "Orders", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateTable( + name: "Implementers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false), + WorkExperience = table.Column(type: "int", nullable: false), + Qualification = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Implementers", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_Orders_ImplementerId", + table: "Orders", + column: "ImplementerId"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders", + column: "ImplementerId", + principalTable: "Implementers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders"); + + migrationBuilder.DropTable( + name: "Implementers"); + + migrationBuilder.DropIndex( + name: "IX_Orders_ImplementerId", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "ImplementerId", + table: "Orders"); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405163724_SixLabWorkTwo.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405163724_SixLabWorkTwo.Designer.cs new file mode 100644 index 0000000..905c2ac --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405163724_SixLabWorkTwo.Designer.cs @@ -0,0 +1,260 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230405163724_SixLabWorkTwo")] + partial class SixLabWorkTwo + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .IsRequired() + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405163724_SixLabWorkTwo.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405163724_SixLabWorkTwo.cs new file mode 100644 index 0000000..3667d34 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405163724_SixLabWorkTwo.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class SixLabWorkTwo : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405174236_SixLabWorkThree.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405174236_SixLabWorkThree.Designer.cs new file mode 100644 index 0000000..9e57db0 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405174236_SixLabWorkThree.Designer.cs @@ -0,0 +1,257 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230405174236_SixLabWorkThree")] + partial class SixLabWorkThree + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405174236_SixLabWorkThree.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405174236_SixLabWorkThree.cs new file mode 100644 index 0000000..38156c3 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405174236_SixLabWorkThree.cs @@ -0,0 +1,59 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class SixLabWorkThree : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders"); + + migrationBuilder.AlterColumn( + name: "ImplementerId", + table: "Orders", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders", + column: "ImplementerId", + principalTable: "Implementers", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders"); + + migrationBuilder.AlterColumn( + name: "ImplementerId", + table: "Orders", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders", + column: "ImplementerId", + principalTable: "Implementers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405194506_SixLabWorkFour.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405194506_SixLabWorkFour.Designer.cs new file mode 100644 index 0000000..14ef963 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405194506_SixLabWorkFour.Designer.cs @@ -0,0 +1,260 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230405194506_SixLabWorkFour")] + partial class SixLabWorkFour + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .IsRequired() + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405194506_SixLabWorkFour.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405194506_SixLabWorkFour.cs new file mode 100644 index 0000000..5dc8e76 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405194506_SixLabWorkFour.cs @@ -0,0 +1,61 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class SixLabWorkFour : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE FROM [dbo].[Orders]"); + + migrationBuilder.DropForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders"); + + migrationBuilder.AlterColumn( + name: "ImplementerId", + table: "Orders", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders", + column: "ImplementerId", + principalTable: "Implementers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders"); + + migrationBuilder.AlterColumn( + name: "ImplementerId", + table: "Orders", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders", + column: "ImplementerId", + principalTable: "Implementers", + principalColumn: "Id"); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405194949_SixLabWorkFive.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405194949_SixLabWorkFive.Designer.cs new file mode 100644 index 0000000..eb2c246 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405194949_SixLabWorkFive.Designer.cs @@ -0,0 +1,257 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230405194949_SixLabWorkFive")] + partial class SixLabWorkFive + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405194949_SixLabWorkFive.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405194949_SixLabWorkFive.cs new file mode 100644 index 0000000..efb208a --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405194949_SixLabWorkFive.cs @@ -0,0 +1,59 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class SixLabWorkFive : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders"); + + migrationBuilder.AlterColumn( + name: "ImplementerId", + table: "Orders", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders", + column: "ImplementerId", + principalTable: "Implementers", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders"); + + migrationBuilder.AlterColumn( + name: "ImplementerId", + table: "Orders", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders", + column: "ImplementerId", + principalTable: "Implementers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405203155_SixLabWorkFix.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405203155_SixLabWorkFix.Designer.cs new file mode 100644 index 0000000..1b34f0e --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405203155_SixLabWorkFix.Designer.cs @@ -0,0 +1,257 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230405203155_SixLabWorkFix")] + partial class SixLabWorkFix + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405203155_SixLabWorkFix.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405203155_SixLabWorkFix.cs new file mode 100644 index 0000000..5780a6d --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230405203155_SixLabWorkFix.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class SixLabWorkFix : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE FROM [dbo].[Orders]"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411082452_ClearBD.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411082452_ClearBD.Designer.cs new file mode 100644 index 0000000..caa422b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411082452_ClearBD.Designer.cs @@ -0,0 +1,257 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230411082452_ClearBD")] + partial class ClearBD + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411082452_ClearBD.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411082452_ClearBD.cs new file mode 100644 index 0000000..20f6655 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411082452_ClearBD.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class ClearBD : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE FROM [dbo].[Orders]"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411084029_ClearBD2.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411084029_ClearBD2.Designer.cs new file mode 100644 index 0000000..29306fa --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411084029_ClearBD2.Designer.cs @@ -0,0 +1,257 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230411084029_ClearBD2")] + partial class ClearBD2 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411084029_ClearBD2.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411084029_ClearBD2.cs new file mode 100644 index 0000000..5f8dff4 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411084029_ClearBD2.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class ClearBD2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE FROM [dbo].[Orders]"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421111331_ClearMigrationForLabWork06HArd.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421111331_ClearMigrationForLabWork06HArd.Designer.cs new file mode 100644 index 0000000..3e33e58 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421111331_ClearMigrationForLabWork06HArd.Designer.cs @@ -0,0 +1,336 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230421111331_ClearMigrationForLabWork06HArd")] + partial class ClearMigrationForLabWork06HArd + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateOpen") + .HasColumnType("datetime2"); + + b.Property("MaxCountManufactures") + .HasColumnType("int"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopManufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Shops") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Shop", "Shop") + .WithMany("Manufactures") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("Shop"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("Shops"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Navigation("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421111331_ClearMigrationForLabWork06HArd.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421111331_ClearMigrationForLabWork06HArd.cs new file mode 100644 index 0000000..e9c9ace --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421111331_ClearMigrationForLabWork06HArd.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class ClearMigrationForLabWork06HArd : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE FROM [dbo].[Orders]"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421142514_SecondClearMigrationForLabWork06HArd.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421142514_SecondClearMigrationForLabWork06HArd.Designer.cs new file mode 100644 index 0000000..8e7f610 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421142514_SecondClearMigrationForLabWork06HArd.Designer.cs @@ -0,0 +1,336 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230421142514_SecondClearMigrationForLabWork06HArd")] + partial class SecondClearMigrationForLabWork06HArd + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateOpen") + .HasColumnType("datetime2"); + + b.Property("MaxCountManufactures") + .HasColumnType("int"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopManufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Shops") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Shop", "Shop") + .WithMany("Manufactures") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("Shop"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("Shops"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Navigation("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421142514_SecondClearMigrationForLabWork06HArd.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421142514_SecondClearMigrationForLabWork06HArd.cs new file mode 100644 index 0000000..a4646bd --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421142514_SecondClearMigrationForLabWork06HArd.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class SecondClearMigrationForLabWork06HArd : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE FROM [dbo].[Orders]"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421154714_Clear.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421154714_Clear.Designer.cs new file mode 100644 index 0000000..d615474 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421154714_Clear.Designer.cs @@ -0,0 +1,336 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230421154714_Clear")] + partial class Clear + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateOpen") + .HasColumnType("datetime2"); + + b.Property("MaxCountManufactures") + .HasColumnType("int"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopManufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Shops") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Shop", "Shop") + .WithMany("Manufactures") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("Shop"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("Shops"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Navigation("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421154714_Clear.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421154714_Clear.cs new file mode 100644 index 0000000..6964c05 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421154714_Clear.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class Clear : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE FROM [dbo].[Orders]"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230425091225_CLearTwo.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230425091225_CLearTwo.Designer.cs new file mode 100644 index 0000000..fc6318d --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230425091225_CLearTwo.Designer.cs @@ -0,0 +1,336 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230425091225_CLearTwo")] + partial class CLearTwo + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateOpen") + .HasColumnType("datetime2"); + + b.Property("MaxCountManufactures") + .HasColumnType("int"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopManufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Shops") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Shop", "Shop") + .WithMany("Manufactures") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("Shop"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("Shops"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Navigation("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230425091225_CLearTwo.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230425091225_CLearTwo.cs new file mode 100644 index 0000000..5e17230 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230425091225_CLearTwo.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class CLearTwo : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE FROM [dbo].[Orders]"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230425094433_CLearThree.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230425094433_CLearThree.Designer.cs new file mode 100644 index 0000000..3d63c2d --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230425094433_CLearThree.Designer.cs @@ -0,0 +1,336 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230425094433_CLearThree")] + partial class CLearThree + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("WorkPieceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("WorkPieceId"); + + b.ToTable("ManufactureWorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateOpen") + .HasColumnType("datetime2"); + + b.Property("MaxCountManufactures") + .HasColumnType("int"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopManufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("WorkPieceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("WorkPieces") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece") + .WithMany("ManufactureWorkPieces") + .HasForeignKey("WorkPieceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("WorkPiece"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Shops") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Shop", "Shop") + .WithMany("Manufactures") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("Shop"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Orders"); + + b.Navigation("Shops"); + + b.Navigation("WorkPieces"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Navigation("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b => + { + b.Navigation("ManufactureWorkPieces"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230425094433_CLearThree.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230425094433_CLearThree.cs new file mode 100644 index 0000000..02f5bdd --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230425094433_CLearThree.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatabaseImplement.Migrations +{ + /// + public partial class CLearThree : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE FROM [dbo].[Orders]"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs index e463b69..0500d99 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs @@ -47,6 +47,33 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations b.ToTable("Clients"); }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => { b.Property("Id") @@ -113,6 +140,9 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations b.Property("DateImplement") .HasColumnType("datetime2"); + b.Property("ImplementerId") + .HasColumnType("int"); + b.Property("ManufactureId") .HasColumnType("int"); @@ -126,6 +156,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.HasIndex("ManufactureId"); b.ToTable("Orders"); @@ -231,6 +263,10 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") .WithMany("Orders") .HasForeignKey("ManufactureId") @@ -239,6 +275,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations b.Navigation("Client"); + b.Navigation("Implementer"); + b.Navigation("Manufacture"); }); @@ -266,6 +304,11 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations b.Navigation("Orders"); }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => { b.Navigation("Orders"); diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Implementer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Implementer.cs new file mode 100644 index 0000000..972afd3 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Implementer.cs @@ -0,0 +1,86 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopDatabaseImplement.Models +{ + public class Implementer : IImplementerModel + { + public int Id { get; set; } + + [Required] + public string ImplementerFIO { get; set; } = string.Empty; + + [Required] + public string Password { get; set; } = string.Empty; + + [Required] + public int WorkExperience { get; set; } + + [Required] + public int Qualification { get; set; } + + //для реализации связи один ко многим с заказами + [ForeignKey("ImplementerId")] + public virtual List Orders { get; set; } = new(); + + public static Implementer? Create(ImplementerBindingModel model) + { + if (model == null) + { + return null; + } + + return new Implementer() + { + Id = model.Id, + Password = model.Password, + ImplementerFIO = model.ImplementerFIO, + Qualification = model.Qualification, + WorkExperience = model.WorkExperience + }; + } + + public static Implementer Create(ImplementerViewModel model) + { + return new Implementer + { + Id = model.Id, + Password = model.Password, + ImplementerFIO = model.ImplementerFIO, + Qualification = model.Qualification, + WorkExperience = model.WorkExperience + }; + } + + public void Update(ImplementerBindingModel model) + { + if (model == null) + { + return; + } + + Id = model.Id; + Password = model.Password; + ImplementerFIO = model.ImplementerFIO; + Qualification = model.Qualification; + WorkExperience = model.WorkExperience; + } + + public ImplementerViewModel GetViewModel => new() + { + Id = Id, + Password = Password, + ImplementerFIO = ImplementerFIO, + Qualification = Qualification, + WorkExperience = WorkExperience + }; + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Order.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Order.cs index cbc9b25..976f6f3 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Order.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Order.cs @@ -22,6 +22,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Models [Required] public int ClientId { get; private set; } + public int? ImplementerId { get; private set; } + [Required] public int Count { get; private set; } @@ -42,7 +44,10 @@ namespace BlacksmithWorkshopDatabaseImplement.Models //для передачи имени клиента public virtual Client Client { get; set; } - public static Order? Create(OrderBindingModel model) + //для передачи имени исполнителя + public virtual Implementer? Implementer { get; set; } + + public static Order? Create(OrderBindingModel model) { if (model == null) { @@ -54,6 +59,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Models Id = model.Id, ManufactureId = model.ManufactureId, ClientId = model.ClientId, + ImplementerId = model.ImplementerId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -69,22 +75,25 @@ namespace BlacksmithWorkshopDatabaseImplement.Models return; } + ImplementerId = model.ImplementerId; Status = model.Status; DateImplement = model.DateImplement; - } + } public OrderViewModel GetViewModel => new() { Id = Id, ManufactureId = ManufactureId, ClientId = ClientId, + ImplementerId = ImplementerId, Count = Count, Sum = Sum, Status = Status, DateCreate = DateCreate, DateImplement = DateImplement, ManufactureName = Manufacture.ManufactureName, - ClientFIO = Client.ClientFIO + ClientFIO = Client.ClientFIO, + ImplementerFIO = Implementer?.ImplementerFIO }; } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Shop.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Shop.cs index d529c67..c74dac1 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Shop.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Shop.cs @@ -36,8 +36,21 @@ namespace BlacksmithWorkshopDatabaseImplement.Models { if (_shopManufactures == null) { - _shopManufactures = Manufactures.ToDictionary(recSI => recSI.ManufactureId, recSI => (recSI.Manufacture as IManufactureModel, recSI.Count)); + _shopManufactures = new(); + + Manufactures.ForEach(x => + { + if (_shopManufactures.ContainsKey(x.ManufactureId)) + { + _shopManufactures[x.ManufactureId] = (x.Manufacture as IManufactureModel, _shopManufactures[x.ManufactureId].Item2 + x.Count); + } + else + { + _shopManufactures[x.ManufactureId] = (x.Manufacture as IManufactureModel, x.Count); + } + }); } + return _shopManufactures; } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/DataFileSingleton.cs b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/DataFileSingleton.cs index efec9bd..23fa07b 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/DataFileSingleton.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/DataFileSingleton.cs @@ -22,6 +22,8 @@ namespace BlacksmithWorkshopFileImplement private readonly string ClientFileName = "Client.xml"; + private readonly string ImplementerFileName = "Implementer.xml"; + public List WorkPieces { get; private set; } public List Orders { get; private set; } @@ -32,6 +34,8 @@ namespace BlacksmithWorkshopFileImplement public List Clients { get; private set; } + public List Implementers { get; private set; } + public static DataFileSingleton GetInstance() { if (instance == null) @@ -52,6 +56,8 @@ namespace BlacksmithWorkshopFileImplement public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement); + public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement); + private DataFileSingleton() { WorkPieces = LoadData(WorkPieceFileName, "WorkPiece", x => WorkPiece.Create(x)!)!; @@ -59,7 +65,8 @@ namespace BlacksmithWorkshopFileImplement Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!; Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!; - } + Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!; + } private static List? LoadData(string filename, string xmlNodeName, Func selectFunction) { diff --git a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/ImplementerStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/ImplementerStorage.cs new file mode 100644 index 0000000..3321ee0 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/ImplementerStorage.cs @@ -0,0 +1,90 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.StoragesContracts; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopFileImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopFileImplement.Implements +{ + public class ImplementerStorage : IImplementerStorage + { + private readonly DataFileSingleton source; + + public ImplementerStorage() + { + source = DataFileSingleton.GetInstance(); + } + + public List GetFullList() + { + return source.Implementers.Select(x => x.GetViewModel).ToList(); + } + + public List GetFilteredList(ImplementerSearchModel model) + { + return source.Implementers.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList(); + } + + public ImplementerViewModel? GetElement(ImplementerSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + + return source.Implementers.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; + } + + public ImplementerViewModel? Insert(ImplementerBindingModel model) + { + model.Id = source.Implementers.Count > 0 ? source.Implementers.Max(x => x.Id) + 1 : 1; + + var newImplementer = Implementer.Create(model); + + if (newImplementer == null) + { + return null; + } + + source.Implementers.Add(newImplementer); + source.SaveImplementers(); + + return newImplementer.GetViewModel; + } + + public ImplementerViewModel? Update(ImplementerBindingModel model) + { + var implementer = source.Implementers.FirstOrDefault(x => x.Id == model.Id); + + if (implementer == null) + { + return null; + } + + implementer.Update(model); + source.SaveImplementers(); + + return implementer.GetViewModel; + } + + public ImplementerViewModel? Delete(ImplementerBindingModel model) + { + var element = source.Implementers.FirstOrDefault(x => x.Id == model.Id); + + if (element != null) + { + source.Implementers.Remove(element); + source.SaveImplementers(); + + return element.GetViewModel; + } + + return null; + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/OrderStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/OrderStorage.cs index 86ea186..d62eeea 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/OrderStorage.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/OrderStorage.cs @@ -34,13 +34,6 @@ namespace BlacksmithWorkshopFileImplement.Implements .Select(x => GetViewModel(x)) .ToList(); } - else if (model.Id.HasValue) - { - return source.Orders - .Where(x => x.Id == model.Id) - .Select(x => GetViewModel(x)) - .ToList(); - } else if (model.ClientId.HasValue) { return source.Orders @@ -48,12 +41,36 @@ namespace BlacksmithWorkshopFileImplement.Implements .Select(x => GetViewModel(x)) .ToList(); } + else if (model.ImplementerId.HasValue) + { + return source.Orders + .Where(x => x.ImplementerId == model.ImplementerId) + .Select(x => GetViewModel(x)) + .ToList(); + } - return new(); + return source.Orders + .Where(x => x.Id == model.Id) + .Select(x => GetViewModel(x)) + .ToList(); } public OrderViewModel? GetElement(OrderSearchModel model) { + if (model.ImplementerId.HasValue && model.Status.HasValue) + { + return source.Orders + .FirstOrDefault(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status) + ?.GetViewModel; + } + + if (model.ImplementerId.HasValue) + { + return source.Orders + .FirstOrDefault(x => x.ImplementerId == model.ImplementerId) + ?.GetViewModel; + } + if (!model.Id.HasValue) { return null; @@ -62,7 +79,7 @@ namespace BlacksmithWorkshopFileImplement.Implements return source.Orders.FirstOrDefault(x =>(model.Id.HasValue && x.Id == model.Id))?.GetViewModel; } - //для загрузки названий изделия в заказе + //для загрузки названий и имён в заказ private OrderViewModel GetViewModel(Order order) { var viewModel = order.GetViewModel; @@ -71,6 +88,8 @@ namespace BlacksmithWorkshopFileImplement.Implements var client = source.Clients.FirstOrDefault(x => x.Id == order.ClientId); + var implementer = source.Implementers.FirstOrDefault(x => x.Id == order.ImplementerId); + if(manufacture != null) { viewModel.ManufactureName = manufacture.ManufactureName; @@ -81,7 +100,12 @@ namespace BlacksmithWorkshopFileImplement.Implements viewModel.ClientFIO = client.ClientFIO; } - return viewModel; + if (implementer != null) + { + viewModel.ImplementerFIO = implementer.ImplementerFIO; + } + + return viewModel; } public OrderViewModel? Insert(OrderBindingModel model) diff --git a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/Implementer.cs b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/Implementer.cs new file mode 100644 index 0000000..21a0148 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/Implementer.cs @@ -0,0 +1,90 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace BlacksmithWorkshopFileImplement.Models +{ + public class Implementer : IImplementerModel + { + public int Id { get; private set; } + + public string ImplementerFIO { get; private set; } = string.Empty; + + public string Password { get; private set; } = string.Empty; + + public int WorkExperience { get; private set; } + + public int Qualification { get; private set; } + + public static Implementer? Create(ImplementerBindingModel model) + { + if (model == null) + { + return null; + } + + return new Implementer() + { + Id = model.Id, + Password = model.Password, + ImplementerFIO = model.ImplementerFIO, + Qualification = model.Qualification, + WorkExperience = model.WorkExperience + }; + } + + public static Implementer? Create(XElement element) + { + if (element == null) + { + return null; + } + + return new Implementer() + { + Id = Convert.ToInt32(element.Attribute("Id")!.Value), + Password = element.Element("Password")!.Value, + ImplementerFIO = element.Element("ImplementerFIO")!.Value, + Qualification = Convert.ToInt32(element.Element("Qualification")!.Value), + WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value) + }; + } + + public void Update(ImplementerBindingModel model) + { + if (model == null) + { + return; + } + + Id = model.Id; + Password = model.Password; + ImplementerFIO = model.ImplementerFIO; + Qualification = model.Qualification; + WorkExperience = model.WorkExperience; + } + + public ImplementerViewModel GetViewModel => new() + { + Id = Id, + Password = Password, + ImplementerFIO = ImplementerFIO, + Qualification = Qualification, + WorkExperience = WorkExperience + }; + + public XElement GetXElement => new("Order", + new XAttribute("Id", Id), + new XElement("Password", Password), + new XElement("ImplementerFIO", ImplementerFIO), + new XElement("Qualification", Qualification), + new XElement("WorkExperience", WorkExperience)); + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/Order.cs b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/Order.cs index dc79c2c..7635cd2 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/Order.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/Order.cs @@ -19,6 +19,8 @@ namespace BlacksmithWorkshopFileImplement.Models public int ClientId { get; private set; } + public int? ImplementerId { get; private set; } + public int ManufactureId { get; private set; } public int Count { get; private set; } @@ -43,6 +45,7 @@ namespace BlacksmithWorkshopFileImplement.Models Id = model.Id, ClientId = model.ClientId, ManufactureId = model.ManufactureId, + ImplementerId = model.ImplementerId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -61,7 +64,8 @@ namespace BlacksmithWorkshopFileImplement.Models return new Order() { Id = Convert.ToInt32(element.Attribute("Id")!.Value), - ClientId = Convert.ToInt32(element.Attribute("Id")!.Value), + ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value), + ImplementerId = Convert.ToInt32(element.Attribute("ImplementerId")!.Value), ManufactureId = Convert.ToInt32(element.Element("ManufactureId")!.Value), Count = Convert.ToInt32(element.Element("Count")!.Value), Sum = Convert.ToDouble(element.Element("Sum")!.Value), @@ -87,7 +91,8 @@ namespace BlacksmithWorkshopFileImplement.Models { Id = Id, ClientId = ClientId, - ManufactureId = ManufactureId, + ImplementerId = ImplementerId, + ManufactureId = ManufactureId, Count = Count, Sum = Sum, Status = Status, @@ -98,6 +103,7 @@ namespace BlacksmithWorkshopFileImplement.Models public XElement GetXElement => new("Order", new XAttribute("Id", Id), new XElement("ClientId", ClientId.ToString()), + new XElement("ImplementerId", ClientId.ToString()), new XElement("ManufactureId", ManufactureId.ToString()), new XElement("Count", Count.ToString()), new XElement("Sum", Sum.ToString()), diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/DataListSingleton.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/DataListSingleton.cs index f57e165..6fee4e3 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/DataListSingleton.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/DataListSingleton.cs @@ -27,13 +27,17 @@ namespace BlacksmithWorkshopListImplement //список для хранения Магазинов public List Clients { get; set; } - public DataListSingleton() + //список для хранения исполнителей + public List Implementers { get; set; } + + public DataListSingleton() { WorkPieces = new List(); Manufactures = new List(); Orders = new List(); Shops = new List(); Clients = new List(); + Implementers = new List(); } public static DataListSingleton GetInstance() diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ImplementerStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ImplementerStorage.cs new file mode 100644 index 0000000..4cbc518 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/ImplementerStorage.cs @@ -0,0 +1,130 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.StoragesContracts; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopListImplement.Implements +{ + public class ImplementerStorage : IImplementerStorage + { + //поле для работы со списком исполнителей + private readonly DataListSingleton _source; + + public ImplementerStorage() + { + _source = DataListSingleton.GetInstance(); + } + + public List GetFullList() + { + var result = new List(); + + foreach (var implementer in _source.Implementers) + { + result.Add(implementer.GetViewModel); + } + + return result; + } + + public List GetFilteredList(ImplementerSearchModel model) + { + var result = new List(); + + if (string.IsNullOrEmpty(model.ImplementerFIO)) + { + return result; + } + + foreach (var implementer in _source.Implementers) + { + if (implementer.ImplementerFIO.Contains(model.ImplementerFIO)) + { + result.Add(implementer.GetViewModel); + } + } + + return result; + } + + public ImplementerViewModel? GetElement(ImplementerSearchModel model) + { + if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.Id.HasValue) + { + return null; + } + + foreach (var implementer in _source.Implementers) + { + if ((!string.IsNullOrEmpty(model.ImplementerFIO) && implementer.ImplementerFIO == model.ImplementerFIO) || + (model.Id.HasValue && implementer.Id == model.Id)) + { + return implementer.GetViewModel; + } + } + + return null; + } + + public ImplementerViewModel? Insert(ImplementerBindingModel model) + { + model.Id = 1; + + foreach (var implementer in _source.Implementers) + { + if (model.Id <= implementer.Id) + { + model.Id = implementer.Id + 1; + } + } + + var newImplementer = Implementer.Create(model); + + if (newImplementer == null) + { + return null; + } + + _source.Implementers.Add(newImplementer); + + return newImplementer.GetViewModel; + } + + public ImplementerViewModel? Update(ImplementerBindingModel model) + { + foreach (var implementer in _source.Implementers) + { + if (implementer.Id == model.Id) + { + implementer.Update(model); + + return implementer.GetViewModel; + } + } + + return null; + } + + public ImplementerViewModel? Delete(ImplementerBindingModel model) + { + for (int i = 0; i < _source.Implementers.Count; ++i) + { + if (_source.Implementers[i].Id == model.Id) + { + var element = _source.Implementers[i]; + _source.Implementers.RemoveAt(i); + + return element.GetViewModel; + } + } + + return null; + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/OrderStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/OrderStorage.cs index 9b08397..2bc0602 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/OrderStorage.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/OrderStorage.cs @@ -39,10 +39,10 @@ namespace BlacksmithWorkshopListImplement.Implements //получение отфильтрованного списка заказов public List GetFilteredList(OrderSearchModel model) { + var result = new List(); + if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) { - var result = new List(); - foreach (var order in _source.Orders) { if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo) @@ -53,20 +53,8 @@ namespace BlacksmithWorkshopListImplement.Implements return result; } - else if (model.Id.HasValue) - { - foreach (var order in _source.Orders) - { - if (order.Id == model.Id) - { - return new() { GetViewModel(order) }; - } - } - } else if (model.ClientId.HasValue) { - var result = new List(); - foreach (var order in _source.Orders) { if (order.ClientId == model.ClientId) @@ -77,8 +65,27 @@ namespace BlacksmithWorkshopListImplement.Implements return result; } + else if (model.Status.HasValue) + { + foreach (var order in _source.Orders) + { + if (order.Status == model.Status) + { + result.Add(GetViewModel(order)); + } + } + return result; + } - return new(); + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + result.Add(GetViewModel(order)); + } + } + + return result; } //получение элемента из списка заказов @@ -100,7 +107,7 @@ namespace BlacksmithWorkshopListImplement.Implements return null; } - //метод для записи названия изделия на форме с заказами + //метод для передачи названий и имён на форму private OrderViewModel GetViewModel(Order order) { var viewModel = order.GetViewModel; @@ -124,6 +131,16 @@ namespace BlacksmithWorkshopListImplement.Implements } } + foreach (var implementer in _source.Implementers) + { + if (implementer.Id == order.ImplementerId) + { + viewModel.ImplementerFIO = implementer.ImplementerFIO; + + break; + } + } + return viewModel; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Implementer.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Implementer.cs new file mode 100644 index 0000000..45a14a4 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Implementer.cs @@ -0,0 +1,67 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopListImplement.Models +{ + public class Implementer : IImplementerModel + { + public int Id { get; private set; } + + public string ImplementerFIO { get; private set; } = string.Empty; + + public string Password { get; private set; } = string.Empty; + + public int WorkExperience { get; private set; } + + public int Qualification { get; private set; } + + //метод для создания объекта от класса-компонента на основе класса-BindingModel + public static Implementer? Create(ImplementerBindingModel? model) + { + if (model == null) + { + return null; + } + + return new Implementer() + { + Id = model.Id, + Password = model.Password, + ImplementerFIO = model.ImplementerFIO, + Qualification = model.Qualification, + WorkExperience = model.WorkExperience + }; + } + + //метод изменения существующего объекта + public void Update(ImplementerBindingModel? model) + { + if (model == null) + { + return; + } + + Password = model.Password; + ImplementerFIO = model.ImplementerFIO; + Qualification = model.Qualification; + WorkExperience = model.WorkExperience; + } + + //метод для создания объекта класса ViewModel на основе данных объекта класса-компонента + public ImplementerViewModel GetViewModel => new() + { + Id = Id, + Password = Password, + ImplementerFIO = ImplementerFIO, + Qualification = Qualification, + WorkExperience = WorkExperience + }; + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order.cs index 533437e..30c3f9e 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/Order.cs @@ -5,6 +5,7 @@ using BlacksmithWorkshopDataModels.Models; using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Reflection.PortableExecutable; using System.Text; using System.Threading.Tasks; @@ -19,6 +20,8 @@ namespace BlacksmithWorkshopListImplement.Models public int ClientId { get; private set; } + public int? ImplementerId { get; private set; } + public int ManufactureId { get; private set; } public int Count { get; private set; } @@ -43,6 +46,7 @@ namespace BlacksmithWorkshopListImplement.Models Id = model.Id, ManufactureId = model.ManufactureId, ClientId = model.ClientId, + ImplementerId = model.ImplementerId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -69,7 +73,8 @@ namespace BlacksmithWorkshopListImplement.Models Id = Id, ManufactureId = ManufactureId, ClientId = ClientId, - Count = Count, + ImplementerId = ImplementerId, + Count = Count, Sum = Sum, Status = Status, DateCreate = DateCreate,