This commit is contained in:
Kate 2023-06-13 22:47:25 +03:00
parent af08524179
commit d43780c207
19 changed files with 995 additions and 622 deletions

View File

@ -1,4 +1,9 @@
using System; using PrecastConcretePlantContracts.BindingModels;
using PrecastConcretePlantContracts.SearchModels;
using PrecastConcretePlantContracts.StoragesContracts;
using PrecastConcretePlantContracts.ViewModels;
using PrecastConcretePlantFileImplement.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -44,32 +49,34 @@ namespace PrecastConcretePlantFileImplement.Implements
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model) public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
{ {
if (model == null) if (model == null)
{ {
return new(); return new();
} }
if (model.Id.HasValue) if (model.Id.HasValue)
{ {
var res = GetElement(model); var res = GetElement(model);
return res != null ? new() { res } : new(); return res != null ? new() { res } : new();
} }
if (model.ImplementerFIO != null) if (model.ImplementerFIO != null)
{ {
return _source.Implementers return _source.Implementers
.Where(x => x.ImplementerFIO.Equals(model.ImplementerFIO)) .Where(x => x.ImplementerFIO.Equals(model.ImplementerFIO))
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
return new(); return new();
} }
public List<ImplementerViewModel> GetFullList() public List<ImplementerViewModel> GetFullList()
{ {
return _source.Implementers.Select(x => x.GetViewModel).ToList(); return _source.Implementers
.Select(x => x.GetViewModel)
.ToList();
} }
public ImplementerViewModel? Insert(ImplementerBindingModel model) public ImplementerViewModel? Insert(ImplementerBindingModel model)

View File

@ -1,8 +1,12 @@
using System; using PrecastConcretePlantContracts.BindingModels;
using PrecastConcretePlantContracts.ViewModels;
using PrecastConcretePlantDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq;
namespace PrecastConcretePlantFileImplement.Models namespace PrecastConcretePlantFileImplement.Models
{ {

View File

@ -1,178 +1,173 @@
namespace PrecastConcretePlantView namespace PrecastConcretePlantView
{ {
partial class FormImplementer partial class FormImplementer
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// Clean up any resources being used. /// Clean up any resources being used.
/// </summary> /// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.buttonSave = new System.Windows.Forms.Button(); buttonSave = new Button();
this.buttonCancel = new System.Windows.Forms.Button(); buttonCancel = new Button();
this.numericUpDownQualification = new System.Windows.Forms.NumericUpDown(); numericUpDownQualification = new NumericUpDown();
this.numericUpDownWorkExperience = new System.Windows.Forms.NumericUpDown(); numericUpDownWorkExperience = new NumericUpDown();
this.textBoxPassword = new System.Windows.Forms.TextBox(); textBoxPassword = new TextBox();
this.textBoxFio = new System.Windows.Forms.TextBox(); textBoxFio = new TextBox();
this.label4 = new System.Windows.Forms.Label(); label4 = new Label();
this.label3 = new System.Windows.Forms.Label(); label3 = new Label();
this.label2 = new System.Windows.Forms.Label(); label2 = new Label();
this.label1 = new System.Windows.Forms.Label(); label1 = new Label();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownQualification).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExperience)).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownWorkExperience).BeginInit();
this.SuspendLayout(); SuspendLayout();
// //
// buttonSave // buttonSave
// //
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
this.buttonSave.Location = new System.Drawing.Point(108, 151); buttonSave.Location = new Point(108, 151);
this.buttonSave.Name = "buttonSave"; buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(89, 33); buttonSave.Size = new Size(89, 33);
this.buttonSave.TabIndex = 19; buttonSave.TabIndex = 19;
this.buttonSave.Text = "Сохранить"; buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true; buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); buttonSave.Click += ButtonSave_Click;
// //
// buttonCancel // buttonCancel
// //
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
this.buttonCancel.Location = new System.Drawing.Point(219, 151); buttonCancel.Location = new Point(219, 151);
this.buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(89, 33); buttonCancel.Size = new Size(89, 33);
this.buttonCancel.TabIndex = 18; buttonCancel.TabIndex = 18;
this.buttonCancel.Text = "Отмена"; buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); buttonCancel.Click += ButtonCancel_Click;
// //
// numericUpDownQualification // numericUpDownQualification
// //
this.numericUpDownQualification.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) numericUpDownQualification.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
| System.Windows.Forms.AnchorStyles.Right))); numericUpDownQualification.Location = new Point(116, 97);
this.numericUpDownQualification.Location = new System.Drawing.Point(116, 97); numericUpDownQualification.Name = "numericUpDownQualification";
this.numericUpDownQualification.Name = "numericUpDownQualification"; numericUpDownQualification.Size = new Size(264, 23);
this.numericUpDownQualification.Size = new System.Drawing.Size(264, 23); numericUpDownQualification.TabIndex = 17;
this.numericUpDownQualification.TabIndex = 17; //
// // numericUpDownWorkExperience
// numericUpDownWorkExperience //
// numericUpDownWorkExperience.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
this.numericUpDownWorkExperience.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) numericUpDownWorkExperience.Location = new Point(116, 68);
| System.Windows.Forms.AnchorStyles.Right))); numericUpDownWorkExperience.Name = "numericUpDownWorkExperience";
this.numericUpDownWorkExperience.Location = new System.Drawing.Point(116, 68); numericUpDownWorkExperience.Size = new Size(264, 23);
this.numericUpDownWorkExperience.Name = "numericUpDownWorkExperience"; numericUpDownWorkExperience.TabIndex = 16;
this.numericUpDownWorkExperience.Size = new System.Drawing.Size(264, 23); //
this.numericUpDownWorkExperience.TabIndex = 16; // textBoxPassword
// //
// textBoxPassword textBoxPassword.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
// textBoxPassword.Location = new Point(116, 40);
this.textBoxPassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) textBoxPassword.Name = "textBoxPassword";
| System.Windows.Forms.AnchorStyles.Right))); textBoxPassword.PasswordChar = '*';
this.textBoxPassword.Location = new System.Drawing.Point(116, 40); textBoxPassword.Size = new Size(264, 23);
this.textBoxPassword.Name = "textBoxPassword"; textBoxPassword.TabIndex = 15;
this.textBoxPassword.PasswordChar = '*'; //
this.textBoxPassword.Size = new System.Drawing.Size(264, 23); // textBoxFio
this.textBoxPassword.TabIndex = 15; //
// textBoxFio.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
// textBoxFio textBoxFio.Location = new Point(116, 11);
// textBoxFio.Name = "textBoxFio";
this.textBoxFio.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) textBoxFio.Size = new Size(264, 23);
| System.Windows.Forms.AnchorStyles.Right))); textBoxFio.TabIndex = 14;
this.textBoxFio.Location = new System.Drawing.Point(116, 11); //
this.textBoxFio.Name = "textBoxFio"; // label4
this.textBoxFio.Size = new System.Drawing.Size(264, 23); //
this.textBoxFio.TabIndex = 14; label4.AutoSize = true;
// label4.Location = new Point(14, 99);
// label4 label4.Name = "label4";
// label4.Size = new Size(91, 15);
this.label4.AutoSize = true; label4.TabIndex = 13;
this.label4.Location = new System.Drawing.Point(14, 99); label4.Text = "Квалификация:";
this.label4.Name = "label4"; //
this.label4.Size = new System.Drawing.Size(91, 15); // label3
this.label4.TabIndex = 13; //
this.label4.Text = "Квалификация:"; label3.AutoSize = true;
// label3.Location = new Point(67, 70);
// label3 label3.Name = "label3";
// label3.Size = new Size(38, 15);
this.label3.AutoSize = true; label3.TabIndex = 12;
this.label3.Location = new System.Drawing.Point(67, 70); label3.Text = "Стаж:";
this.label3.Name = "label3"; //
this.label3.Size = new System.Drawing.Size(38, 15); // label2
this.label3.TabIndex = 12; //
this.label3.Text = "Стаж:"; label2.AutoSize = true;
// label2.Location = new Point(58, 43);
// label2 label2.Name = "label2";
// label2.Size = new Size(52, 15);
this.label2.AutoSize = true; label2.TabIndex = 11;
this.label2.Location = new System.Drawing.Point(58, 43); label2.Text = "Пароль:";
this.label2.Name = "label2"; //
this.label2.Size = new System.Drawing.Size(52, 15); // label1
this.label2.TabIndex = 11; //
this.label2.Text = "Пароль:"; label1.AutoSize = true;
// label1.Location = new Point(68, 14);
// label1 label1.Name = "label1";
// label1.Size = new Size(37, 15);
this.label1.AutoSize = true; label1.TabIndex = 10;
this.label1.Location = new System.Drawing.Point(68, 14); label1.Text = "ФИО:";
this.label1.Name = "label1"; //
this.label1.Size = new System.Drawing.Size(37, 15); // FormImplementer
this.label1.TabIndex = 10; //
this.label1.Text = "ФИО:"; AutoScaleDimensions = new SizeF(7F, 15F);
// AutoScaleMode = AutoScaleMode.Font;
// FormImplementer ClientSize = new Size(402, 196);
// Controls.Add(buttonSave);
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); Controls.Add(buttonCancel);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; Controls.Add(numericUpDownQualification);
this.ClientSize = new System.Drawing.Size(402, 196); Controls.Add(numericUpDownWorkExperience);
this.Controls.Add(this.buttonSave); Controls.Add(textBoxPassword);
this.Controls.Add(this.buttonCancel); Controls.Add(textBoxFio);
this.Controls.Add(this.numericUpDownQualification); Controls.Add(label4);
this.Controls.Add(this.numericUpDownWorkExperience); Controls.Add(label3);
this.Controls.Add(this.textBoxPassword); Controls.Add(label2);
this.Controls.Add(this.textBoxFio); Controls.Add(label1);
this.Controls.Add(this.label4); Name = "FormImplementer";
this.Controls.Add(this.label3); Text = "Исполнитель";
this.Controls.Add(this.label2); Load += FormImplementer_Load;
this.Controls.Add(this.label1); ((System.ComponentModel.ISupportInitialize)numericUpDownQualification).EndInit();
this.Name = "FormImplementer"; ((System.ComponentModel.ISupportInitialize)numericUpDownWorkExperience).EndInit();
this.Text = "FormImplementer"; ResumeLayout(false);
this.Load += new System.EventHandler(this.FormImplementer_Load); PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).EndInit(); }
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExperience)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
} #endregion
#endregion private Button buttonSave;
private Button buttonCancel;
private Button buttonSave; private NumericUpDown numericUpDownQualification;
private Button buttonCancel; private NumericUpDown numericUpDownWorkExperience;
private NumericUpDown numericUpDownQualification; private TextBox textBoxPassword;
private NumericUpDown numericUpDownWorkExperience; private TextBox textBoxFio;
private TextBox textBoxPassword; private Label label4;
private TextBox textBoxFio; private Label label3;
private Label label4; private Label label2;
private Label label3; private Label label1;
private Label label2; }
private Label label1;
}
} }

View File

@ -5,96 +5,96 @@ using PrecastConcretePlantContracts.SearchModels;
namespace PrecastConcretePlantView namespace PrecastConcretePlantView
{ {
public partial class FormImplementer : Form public partial class FormImplementer : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IImplementerLogic _logic; private readonly IImplementerLogic _logic;
private int? _id; private int? _id;
public int Id { set { _id = value; } } public int Id { set { _id = value; } }
public FormImplementer(ILogger<FormImplementer> logger, IImplementerLogic logic) public FormImplementer(ILogger<FormImplementer> logger, IImplementerLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;
} }
private void FormImplementer_Load(object sender, EventArgs e) private void FormImplementer_Load(object sender, EventArgs e)
{ {
if (_id.HasValue) if (_id.HasValue)
{ {
try try
{ {
_logger.LogInformation("Получение исполнителя"); _logger.LogInformation("Получение исполнителя");
var view = _logic.ReadElement(new ImplementerSearchModel var view = _logic.ReadElement(new ImplementerSearchModel
{ {
Id = _id.Value Id = _id.Value
}); });
if (view != null) if (view != null)
{ {
textBoxFio.Text = view.ImplementerFIO; textBoxFio.Text = view.ImplementerFIO;
textBoxPassword.Text = view.Password; textBoxPassword.Text = view.Password;
numericUpDownQualification.Value = view.Qualification; numericUpDownQualification.Value = view.Qualification;
numericUpDownWorkExperience.Value = view.WorkExperience; numericUpDownWorkExperience.Value = view.WorkExperience;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка получения исполнителя"); _logger.LogError(ex, "Ошибка получения исполнителя");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error); MessageBoxIcon.Error);
} }
} }
} }
private void ButtonSave_Click(object sender, EventArgs e) private void ButtonSave_Click(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(textBoxPassword.Text)) if (string.IsNullOrEmpty(textBoxPassword.Text))
{ {
MessageBox.Show("Заполните пароль", "Ошибка", MessageBox.Show("Заполните пароль", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (string.IsNullOrEmpty(textBoxFio.Text)) if (string.IsNullOrEmpty(textBoxFio.Text))
{ {
MessageBox.Show("Заполните фио", "Ошибка", MessageBox.Show("Заполните фио", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
_logger.LogInformation("Сохранение исполнителя"); _logger.LogInformation("Сохранение исполнителя");
try try
{ {
var model = new ImplementerBindingModel var model = new ImplementerBindingModel
{ {
Id = _id ?? 0, Id = _id ?? 0,
ImplementerFIO = textBoxFio.Text, ImplementerFIO = textBoxFio.Text,
Password = textBoxPassword.Text, Password = textBoxPassword.Text,
Qualification = (int)numericUpDownQualification.Value, Qualification = (int)numericUpDownQualification.Value,
WorkExperience = (int)numericUpDownWorkExperience.Value, WorkExperience = (int)numericUpDownWorkExperience.Value,
}; };
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
} }
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка сохранения исполнителя"); _logger.LogError(ex, "Ошибка сохранения исполнителя");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error); MessageBoxIcon.Error);
} }
} }
private void ButtonCancel_Click(object sender, EventArgs e) private void ButtonCancel_Click(object sender, EventArgs e)
{ {
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
} }
} }
} }

View File

@ -1,121 +1,118 @@
namespace PrecastConcretePlantView namespace PrecastConcretePlantView
{ {
partial class FormImplementers partial class FormImplementers
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// Clean up any resources being used. /// Clean up any resources being used.
/// </summary> /// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.buttonRef = new System.Windows.Forms.Button(); buttonRef = new Button();
this.buttonDel = new System.Windows.Forms.Button(); buttonDel = new Button();
this.buttonUpd = new System.Windows.Forms.Button(); buttonUpd = new Button();
this.buttonAdd = new System.Windows.Forms.Button(); buttonAdd = new Button();
this.dataGridView = new System.Windows.Forms.DataGridView(); dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
this.SuspendLayout(); SuspendLayout();
// //
// buttonRef // buttonRef
// //
this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right;
this.buttonRef.Location = new System.Drawing.Point(532, 149); buttonRef.Location = new Point(532, 149);
this.buttonRef.Name = "buttonRef"; buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(90, 37); buttonRef.Size = new Size(90, 37);
this.buttonRef.TabIndex = 14; buttonRef.TabIndex = 14;
this.buttonRef.Text = "Обновить"; buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true; buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); buttonRef.Click += ButtonRef_Click;
// //
// buttonDel // buttonDel
// //
this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); buttonDel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
this.buttonDel.Location = new System.Drawing.Point(532, 110); buttonDel.Location = new Point(532, 110);
this.buttonDel.Name = "buttonDel"; buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(90, 33); buttonDel.Size = new Size(90, 33);
this.buttonDel.TabIndex = 13; buttonDel.TabIndex = 13;
this.buttonDel.Text = "Удалить"; buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true; buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); buttonDel.Click += ButtonDel_Click;
// //
// buttonUpd // buttonUpd
// //
this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); buttonUpd.Anchor = AnchorStyles.Top | AnchorStyles.Right;
this.buttonUpd.Location = new System.Drawing.Point(532, 70); buttonUpd.Location = new Point(532, 70);
this.buttonUpd.Name = "buttonUpd"; buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(90, 34); buttonUpd.Size = new Size(90, 34);
this.buttonUpd.TabIndex = 12; buttonUpd.TabIndex = 12;
this.buttonUpd.Text = "Изменить"; buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true; buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); buttonUpd.Click += ButtonUpd_Click;
// //
// buttonAdd // buttonAdd
// //
this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); buttonAdd.Anchor = AnchorStyles.Top | AnchorStyles.Right;
this.buttonAdd.Location = new System.Drawing.Point(532, 34); buttonAdd.Location = new Point(532, 34);
this.buttonAdd.Name = "buttonAdd"; buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(90, 30); buttonAdd.Size = new Size(90, 30);
this.buttonAdd.TabIndex = 11; buttonAdd.TabIndex = 11;
this.buttonAdd.Text = "Добавить"; buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true; buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); buttonAdd.Click += ButtonAdd_Click;
// //
// dataGridView // dataGridView
// //
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
| System.Windows.Forms.AnchorStyles.Left) dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
| System.Windows.Forms.AnchorStyles.Right))); dataGridView.Location = new Point(12, 12);
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.Name = "dataGridView";
this.dataGridView.Location = new System.Drawing.Point(12, 12); dataGridView.RowTemplate.Height = 25;
this.dataGridView.Name = "dataGridView"; dataGridView.Size = new Size(469, 290);
this.dataGridView.RowTemplate.Height = 25; dataGridView.TabIndex = 10;
this.dataGridView.Size = new System.Drawing.Size(469, 290); //
this.dataGridView.TabIndex = 10; // FormImplementers
// //
// FormViewImplementers AutoScaleDimensions = new SizeF(7F, 15F);
// AutoScaleMode = AutoScaleMode.Font;
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); ClientSize = new Size(634, 314);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; Controls.Add(buttonRef);
this.ClientSize = new System.Drawing.Size(634, 314); Controls.Add(buttonDel);
this.Controls.Add(this.buttonRef); Controls.Add(buttonUpd);
this.Controls.Add(this.buttonDel); Controls.Add(buttonAdd);
this.Controls.Add(this.buttonUpd); Controls.Add(dataGridView);
this.Controls.Add(this.buttonAdd); Name = "FormImplementers";
this.Controls.Add(this.dataGridView); Text = "Исполнители";
this.Name = "FormViewImplementers"; Load += FormViewImplementers_Load;
this.Text = "FormViewImplementers"; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
this.Load += new System.EventHandler(this.FormViewImplementers_Load); ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); }
this.ResumeLayout(false);
} #endregion
#endregion private Button buttonRef;
private Button buttonDel;
private Button buttonRef; private Button buttonUpd;
private Button buttonDel; private Button buttonAdd;
private Button buttonUpd; private DataGridView dataGridView;
private Button buttonAdd; }
private DataGridView dataGridView;
}
} }

View File

@ -5,99 +5,99 @@ using PrecastConcretePlantContracts.BusinessLogicsContracts;
namespace PrecastConcretePlantView namespace PrecastConcretePlantView
{ {
public partial class FormImplementers : Form public partial class FormImplementers : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IImplementerLogic _logic; private readonly IImplementerLogic _logic;
public FormImplementers(ILogger<FormImplementers> logger, IImplementerLogic logic) public FormImplementers(ILogger<FormImplementers> logger, IImplementerLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;
} }
private void FormViewImplementers_Load(object sender, EventArgs e) private void FormViewImplementers_Load(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private void LoadData() private void LoadData()
{ {
try try
{ {
var list = _logic.ReadList(null); var list = _logic.ReadList(null);
if (list != null) if (list != null)
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false; dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
} }
_logger.LogInformation("Загрузка исполнителей"); _logger.LogInformation("Загрузка исполнителей");
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки исполнителей"); _logger.LogError(ex, "Ошибка загрузки исполнителей");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error); MessageBoxIcon.Error);
} }
} }
private void ButtonAdd_Click(object sender, EventArgs e) private void ButtonAdd_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
if (service is FormImplementer form) if (service is FormImplementer form)
{ {
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
LoadData(); LoadData();
} }
} }
} }
private void ButtonUpd_Click(object sender, EventArgs e) private void ButtonUpd_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
if (service is FormImplementer form) if (service is FormImplementer form)
{ {
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
LoadData(); LoadData();
} }
} }
} }
} }
private void ButtonDel_Click(object sender, EventArgs e) private void ButtonDel_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
if (MessageBox.Show("Удалить запись?", "Вопрос", if (MessageBox.Show("Удалить запись?", "Вопрос",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{ {
int id = int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление исполнителя"); _logger.LogInformation("Удаление исполнителя");
try try
{ {
if (!_logic.Delete(new ImplementerBindingModel if (!_logic.Delete(new ImplementerBindingModel
{ {
Id = id Id = id
})) }))
{ {
throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
} }
LoadData(); LoadData();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка удаления исполнителя"); _logger.LogError(ex, "Ошибка удаления исполнителя");
MessageBox.Show(ex.Message, "Ошибка", MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }
} }
private void ButtonRef_Click(object sender, EventArgs e) private void ButtonRef_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
} }
} }

View File

@ -50,23 +50,22 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic
return true; return true;
} }
public OrderViewModel? ReadElement(OrderSearchModel model) public OrderViewModel? ReadElement(OrderSearchModel model)
private bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus) {
{ if (model == null)
if (model == null) {
{ throw new ArgumentNullException(nameof(model));
throw new ArgumentNullException(nameof(model)); }
} _logger.LogInformation("ReadElement. DateFrom:{DateFrom}. DateTo:{DateTo}. Id:{Id}", model.DateFrom, model.DateTo, model.Id);
_logger.LogInformation("ReadElement. DateFrom:{DateFrom}. DateTo:{DateTo}. Id:{Id}", model.DateFrom, model.DateTo, model.Id); var element = _orderStorage.GetElement(model);
var element = _orderStorage.GetElement(model); if (element == null)
if (element == null) {
{ _logger.LogWarning("ReadElement element not found");
_logger.LogWarning("ReadElement element not found"); return null;
return null; }
} _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id); return element;
return element; }
}
private bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus) private bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
{ {
@ -75,56 +74,46 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic
{ {
throw new ArgumentNullException(nameof(model)); throw new ArgumentNullException(nameof(model));
} }
if (viewModel.Status + 1 != newStatus) if (viewModel.Status + 1 != newStatus && viewModel.Status != OrderStatus.Ожидание)
{ {
_logger.LogWarning("Change status operation failed"); _logger.LogWarning("Change status operation failed");
throw new InvalidOperationException(); throw new InvalidOperationException();
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
if (viewModel == null)
{
throw new ArgumentNullException(nameof(model));
}
if (viewModel.Status + 1 != newStatus)
{
_logger.LogWarning("Change status operation failed");
return false;
} }
model.Status = newStatus; model.Status = newStatus;
if (model.Status == OrderStatus.Готов) if (model.Status == OrderStatus.Готов || viewModel.Status == OrderStatus.Ожидание)
{ {
model.DateImplement = DateTime.Now; model.DateImplement = DateTime.Now;
} var reinforced = _reinforcedStorage.GetElement(new() { Id = viewModel.ReinforcedId });
else if (reinforced == null)
{ {
model.DateImplement = viewModel.DateImplement; throw new ArgumentNullException(nameof(reinforced));
} }
if (viewModel.ImplementerId.HasValue) if (!_shopLogic.AddReinforced(reinforced, viewModel.Count))
{ {
model.ImplementerId = viewModel.ImplementerId.Value; model.Status = OrderStatus.Ожидание;
} _logger.LogWarning($"AddReinforced operation failed");
CheckModel(model, false); }
var reinforced = _reinforcedStorage.GetElement(new() { Id = viewModel.ReinforcedId }); else
if (reinforced == null) {
{ model.DateImplement = DateTime.Now;
throw new ArgumentNullException(nameof(reinforced)); }
} }
if (!_shopLogic.AddReinforced(reinforced, viewModel.Count)) else
{ {
throw new Exception($"AddReinforced operation failed"); model.DateImplement = viewModel.DateImplement;
} }
} if (viewModel.ImplementerId.HasValue)
else {
{ model.ImplementerId = viewModel.ImplementerId.Value;
model.DateImplement = viewModel.DateImplement; }
} CheckModel(model, false);
CheckModel(model, false); if (_orderStorage.Update(model) == null)
if (_orderStorage.Update(model) == null) {
{ _logger.LogWarning("Change status operation failed");
_logger.LogWarning("Change status operation failed"); return false;
return false; }
} return true;
return true; }
}
public bool TakeOrderInWork(OrderBindingModel model) public bool TakeOrderInWork(OrderBindingModel model)
{ {

View File

@ -173,7 +173,11 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic
foreach (var shop in _shopStorage.GetFullList()) foreach (var shop in _shopStorage.GetFullList())
{ {
int freeQuantity = shop.Capacity - shop.ShopReinforceds.Select(x => x.Value.Item2).Sum(); int freeQuantity = shop.Capacity - shop.ShopReinforceds.Select(x => x.Value.Item2).Sum();
if (freeQuantity < count) if (freeQuantity == 0)
{
continue;
}
if (freeQuantity < count)
{ {
if (!AddReinforcedInShop(new() { Id = shop.Id }, model, freeQuantity)) if (!AddReinforcedInShop(new() { Id = shop.Id }, model, freeQuantity))
{ {

View File

@ -36,7 +36,7 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic
return; return;
} }
var orders = _orderLogic.ReadList(new OrderSearchModel { Status = new() { OrderStatus.Принят, OrderStatus.Выполняется } }); var orders = _orderLogic.ReadList(new OrderSearchModel { Statuses = new() { OrderStatus.Принят, OrderStatus.Выполняется,OrderStatus.Ожидание } });
if (orders == null || orders.Count == 0) if (orders == null || orders.Count == 0)
{ {
_logger.LogWarning("DoWork. Orders is null or empty"); _logger.LogWarning("DoWork. Orders is null or empty");
@ -51,55 +51,73 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic
} }
} }
private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders) private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders)
{ {
if (_orderLogic == null || implementer == null) if (_orderLogic == null || implementer == null)
{ {
return; return;
} }
await RunOrderInWork(implementer, orders); await RunOrderInWork(implementer, orders);
await Task.Run(() => await Task.Run(() =>
{ {
foreach (var order in orders) foreach (var order in orders.Where(x => x.Status == OrderStatus.Ожидание && x.ImplementerId == implementer.Id))
{ {
try try
{ {
_logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id); _orderLogic.DeliveryOrder(new OrderBindingModel
{
Id = order.Id
});
}
catch (InvalidOperationException ex)
{
_logger.LogWarning(ex, "Error try get work");
}
catch (Exception ex)
{
_logger.LogError(ex, "Error while do work");
throw;
}
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
}
});
_orderLogic.TakeOrderInWork(new OrderBindingModel await RunOrderInWork(implementer, orders);
{
Id = order.Id,
ImplementerId = implementer.Id
});
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count); await Task.Run(() =>
{
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id); foreach (var order in orders.Where(x => x.Status == OrderStatus.Принят))
{
_orderLogic.DeliveryOrder(new OrderBindingModel try
{ {
Id = order.Id _logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id);
}); _orderLogic.TakeOrderInWork(new OrderBindingModel
{
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); Id = order.Id,
} ImplementerId = implementer.Id
});
catch (InvalidOperationException ex) Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
{ _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
_logger.LogWarning(ex, "Error try get work"); _orderLogic.DeliveryOrder(new OrderBindingModel
} {
Id = order.Id
catch (Exception ex) });
{ Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
_logger.LogError(ex, "Error while do work"); }
throw; catch (InvalidOperationException ex)
} {
} _logger.LogWarning(ex, "Error try get work");
}); }
} catch (Exception ex)
{
private async Task RunOrderInWork(ImplementerViewModel implementer, List<OrderViewModel> allOrders) _logger.LogError(ex, "Error while do work");
throw;
}
}
});
}
private async Task RunOrderInWork(ImplementerViewModel implementer, List<OrderViewModel> allOrders)
{ {
if (_orderLogic == null || implementer == null || allOrders == null || allOrders.Count == 0) if (_orderLogic == null || implementer == null || allOrders == null || allOrders.Count == 0)
{ {

View File

@ -38,7 +38,7 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
if (model.ImplementerFIO != null) if (model.ImplementerFIO != null)
{ {
using var context = new SoftwareInstallationDataBase(); using var context = new PrecastConcretePlantDatabase();
return context.Implementers return context.Implementers
.Where(x => x.ImplementerFIO.Equals(model.ImplementerFIO)) .Where(x => x.ImplementerFIO.Equals(model.ImplementerFIO))

View File

@ -0,0 +1,334 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PrecastConcretePlantDatabaseImplement;
#nullable disable
namespace PrecastConcretePlantDatabaseImplement.Migrations
{
[DbContext(typeof(PrecastConcretePlantDatabase))]
[Migration("20230613193850_lab6h")]
partial class lab6h
{
/// <inheritdoc />
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("PrecastConcretePlantDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Qualification")
.HasColumnType("int");
b.Property<int>("WorkExperience")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int?>("ImplementerId")
.HasColumnType("int");
b.Property<int>("ReinforcedId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ImplementerId");
b.HasIndex("ReinforcedId");
b.ToTable("Orders");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Reinforced", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<double>("Price")
.HasColumnType("float");
b.Property<string>("ReinforcedName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Reinforceds");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ReinforcedComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ReinforcedId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("ReinforcedId");
b.ToTable("ReinforcedComponents");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ShopReinforced", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ReinforcedId")
.HasColumnType("int");
b.Property<int>("ShopId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ReinforcedId");
b.HasIndex("ShopId");
b.ToTable("ShopReinforceds");
});
modelBuilder.Entity("Shop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Capacity")
.HasColumnType("int");
b.Property<DateTime>("DateOpening")
.HasColumnType("datetime2");
b.Property<string>("ShopName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Shops");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Order", b =>
{
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Implementer", "Implementer")
.WithMany("Orders")
.HasForeignKey("ImplementerId");
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Reinforced", "Reinforced")
.WithMany("Orders")
.HasForeignKey("ReinforcedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
b.Navigation("Implementer");
b.Navigation("Reinforced");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ReinforcedComponent", b =>
{
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Component", "Component")
.WithMany("ReinforcedComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Reinforced", "Reinforced")
.WithMany("Components")
.HasForeignKey("ReinforcedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Reinforced");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ShopReinforced", b =>
{
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Reinforced", "Reinforced")
.WithMany()
.HasForeignKey("ReinforcedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Shop", "Shop")
.WithMany("Reinforceds")
.HasForeignKey("ShopId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Reinforced");
b.Navigation("Shop");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Component", b =>
{
b.Navigation("ReinforcedComponents");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Implementer", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Reinforced", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
modelBuilder.Entity("Shop", b =>
{
b.Navigation("Reinforceds");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PrecastConcretePlantDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class lab6h : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -5,6 +5,7 @@ using PrecastConcretePlantDatabaseImplement.Models;
using PrecastConcretePlantDataModels.Models; using PrecastConcretePlantDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Security.Cryptography.X509Certificates;
public class Shop : IShopModel public class Shop : IShopModel
{ {
@ -27,7 +28,10 @@ public class Shop : IShopModel
{ {
if (_shopReinforceds == null) if (_shopReinforceds == null)
{ {
_shopReinforceds = Reinforceds.ToDictionary(rec => rec.ReinforcedId, rec => (rec.Reinforced as IReinforcedModel, rec.Count)); using var context = new PrecastConcretePlantDatabase();
_shopReinforceds = Reinforceds
.ToDictionary(rec => rec.ReinforcedId, rec => (context.Reinforceds
.FirstOrDefault(rec1 => rec1.Id == rec.ReinforcedId)! as IReinforcedModel, rec.Count));
} }
return _shopReinforceds; return _shopReinforceds;
} }

View File

@ -12,7 +12,8 @@ namespace PrecastConcretePlantDataModels.Enums
Принят = 0, Принят = 0,
Выполняется = 1, Выполняется = 1,
Готов = 2, Готов = 2,
Выдан = 3 Выдан = 3,
Ожидание=4
} }
} }

View File

@ -2,6 +2,7 @@
using PrecastConcretePlantContracts.SearchModels; using PrecastConcretePlantContracts.SearchModels;
using PrecastConcretePlantContracts.StoragesContracts; using PrecastConcretePlantContracts.StoragesContracts;
using PrecastConcretePlantContracts.ViewModels; using PrecastConcretePlantContracts.ViewModels;
using PrecastConcretePlantListImplement.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -36,31 +36,26 @@ namespace PrecastConcretePlantListImplement.Implements
public OrderViewModel? GetElement(OrderSearchModel model) public OrderViewModel? GetElement(OrderSearchModel model)
{ {
if (!model.Id.HasValue) if (model.Id.HasValue)
{ {
return null; foreach (var order in _source.Orders)
}
foreach (var order in _source.Orders)
{
if (model.Id.HasValue && order.Id == model.Id)
{ {
return order.GetViewModel; if (model.Id.HasValue && order.Id == model.Id)
} {
else if (model.ImplementerId.HasValue && model.Statuses != null && return order.GetViewModel;
order.ImplementerId == model.ImplementerId && }
model.Statuses.Contains(order.Status)) }
{ }
return GetViewModel(order); else if (model.ImplementerId.HasValue && model.Statuses!=null)
} {
foreach (var order in _source.Orders)
else if (model.ImplementerId.HasValue && {
model.ImplementerId == order.ImplementerId) if (model.ImplementerId == order.ImplementerId && model.Statuses.Contains(order.Status))
{ {
return GetViewModel(order); return order.GetViewModel;
}
} }
} }
return null; return null;
} }
@ -86,7 +81,7 @@ namespace PrecastConcretePlantListImplement.Implements
result.Add(order.GetViewModel); result.Add(order.GetViewModel);
} }
else if (model.Status != null && model.Status.Contains(order.Status)) else if (model.Statuses != null && model.Statuses.Contains(order.Status))
{ {
result.Add(order.GetViewModel); result.Add(order.GetViewModel);
} }

View File

@ -54,6 +54,7 @@ namespace PrecastConcretePlantListImplement.Models
Id = Id, Id = Id,
Password = Password, Password = Password,
Qualification = Qualification, Qualification = Qualification,
WorkExperience=WorkExperience,
ImplementerFIO = ImplementerFIO, ImplementerFIO = ImplementerFIO,
}; };
} }

View File

@ -55,6 +55,7 @@ namespace PrecastConcretePlantListImplement.Models
} }
Status = model.Status; Status = model.Status;
DateImplement = model.DateImplement; DateImplement = model.DateImplement;
ImplementerId = model.ImplementerId;
} }
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel => new()
@ -66,7 +67,7 @@ namespace PrecastConcretePlantListImplement.Models
Sum = Sum, Sum = Sum,
Status = Status, Status = Status,
DateCreate = DateCreate, DateCreate = DateCreate,
ImplementerId= ImplementerId, ImplementerId = ImplementerId,
DateImplement = DateImplement DateImplement = DateImplement
}; };
} }

View File

@ -46,7 +46,7 @@ namespace PrecastConcretePlantRestApi.Controllers
{ {
return _order.ReadList(new OrderSearchModel return _order.ReadList(new OrderSearchModel
{ {
Status = new() { OrderStatus.Принят } Statuses = new() { OrderStatus.Принят }
}); });
} }
catch (Exception ex) catch (Exception ex)