PIbd-22. Stroev V.M. Lab Work 06 #6
@ -1,31 +1,31 @@
|
|||||||
namespace PlumbingRepairView
|
namespace PlumbingRepairView
|
||||||
{
|
{
|
||||||
partial class FormCreateOrder
|
partial class FormCreateOrder
|
||||||
{
|
{
|
||||||
/// <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()
|
||||||
{
|
{
|
||||||
label1 = new Label();
|
label1 = new Label();
|
||||||
@ -129,15 +129,15 @@
|
|||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Label label1;
|
private Label label1;
|
||||||
private Label label2;
|
private Label label2;
|
||||||
private Label label3;
|
private Label label3;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private TextBox textBoxCount;
|
private TextBox textBoxCount;
|
||||||
private TextBox textBoxSum;
|
private TextBox textBoxSum;
|
||||||
private ComboBox comboBoxWork;
|
private ComboBox comboBoxWork;
|
||||||
}
|
}
|
||||||
}
|
}
|
176
PlumbingRepair/PlumbingRepair/FormImplementer.Designer.cs
generated
Normal file
176
PlumbingRepair/PlumbingRepair/FormImplementer.Designer.cs
generated
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
|
||||||
|
namespace PlumbingRepair
|
||||||
|
{
|
||||||
|
partial class FormImplementer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
FIOTextBox = new TextBox();
|
||||||
|
PasswordTextBox = new TextBox();
|
||||||
|
LabelFIO = new Label();
|
||||||
|
LabelPassword = new Label();
|
||||||
|
QualificationNumericUpDown = new NumericUpDown();
|
||||||
|
WorkExpNumericUpDown = new NumericUpDown();
|
||||||
|
LabelWorkExperience = new Label();
|
||||||
|
LabelQualification = new Label();
|
||||||
|
ButtonCancel = new Button();
|
||||||
|
ButtonSave = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)QualificationNumericUpDown).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)WorkExpNumericUpDown).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// FIOTextBox
|
||||||
|
//
|
||||||
|
FIOTextBox.Location = new Point(128, 16);
|
||||||
|
FIOTextBox.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
FIOTextBox.Name = "FIOTextBox";
|
||||||
|
FIOTextBox.Size = new Size(194, 27);
|
||||||
|
FIOTextBox.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// PasswordTextBox
|
||||||
|
//
|
||||||
|
PasswordTextBox.Location = new Point(128, 65);
|
||||||
|
PasswordTextBox.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
PasswordTextBox.Name = "PasswordTextBox";
|
||||||
|
PasswordTextBox.Size = new Size(194, 27);
|
||||||
|
PasswordTextBox.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// LabelFIO
|
||||||
|
//
|
||||||
|
LabelFIO.AutoSize = true;
|
||||||
|
LabelFIO.Location = new Point(14, 20);
|
||||||
|
LabelFIO.Name = "LabelFIO";
|
||||||
|
LabelFIO.Size = new Size(49, 20);
|
||||||
|
LabelFIO.TabIndex = 2;
|
||||||
|
LabelFIO.Text = "ФИО: ";
|
||||||
|
//
|
||||||
|
// LabelPassword
|
||||||
|
//
|
||||||
|
LabelPassword.AutoSize = true;
|
||||||
|
LabelPassword.Location = new Point(14, 69);
|
||||||
|
LabelPassword.Name = "LabelPassword";
|
||||||
|
LabelPassword.Size = new Size(69, 20);
|
||||||
|
LabelPassword.TabIndex = 3;
|
||||||
|
LabelPassword.Text = "Пароль: ";
|
||||||
|
//
|
||||||
|
// QualificationNumericUpDown
|
||||||
|
//
|
||||||
|
QualificationNumericUpDown.Location = new Point(128, 175);
|
||||||
|
QualificationNumericUpDown.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
QualificationNumericUpDown.Name = "QualificationNumericUpDown";
|
||||||
|
QualificationNumericUpDown.Size = new Size(194, 27);
|
||||||
|
QualificationNumericUpDown.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// WorkExpNumericUpDown
|
||||||
|
//
|
||||||
|
WorkExpNumericUpDown.Location = new Point(128, 120);
|
||||||
|
WorkExpNumericUpDown.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
WorkExpNumericUpDown.Name = "WorkExpNumericUpDown";
|
||||||
|
WorkExpNumericUpDown.Size = new Size(194, 27);
|
||||||
|
WorkExpNumericUpDown.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// LabelWorkExperience
|
||||||
|
//
|
||||||
|
LabelWorkExperience.AutoSize = true;
|
||||||
|
LabelWorkExperience.Location = new Point(14, 123);
|
||||||
|
LabelWorkExperience.Name = "LabelWorkExperience";
|
||||||
|
LabelWorkExperience.Size = new Size(109, 20);
|
||||||
|
LabelWorkExperience.TabIndex = 6;
|
||||||
|
LabelWorkExperience.Text = "Опыт работы: ";
|
||||||
|
//
|
||||||
|
// LabelQualification
|
||||||
|
//
|
||||||
|
LabelQualification.AutoSize = true;
|
||||||
|
LabelQualification.Location = new Point(5, 177);
|
||||||
|
LabelQualification.Name = "LabelQualification";
|
||||||
|
LabelQualification.Size = new Size(118, 20);
|
||||||
|
LabelQualification.TabIndex = 7;
|
||||||
|
LabelQualification.Text = "Квалификация: ";
|
||||||
|
//
|
||||||
|
// ButtonCancel
|
||||||
|
//
|
||||||
|
ButtonCancel.Location = new Point(211, 225);
|
||||||
|
ButtonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
ButtonCancel.Name = "ButtonCancel";
|
||||||
|
ButtonCancel.Size = new Size(111, 39);
|
||||||
|
ButtonCancel.TabIndex = 8;
|
||||||
|
ButtonCancel.Text = "Отмена";
|
||||||
|
ButtonCancel.UseVisualStyleBackColor = true;
|
||||||
|
ButtonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// ButtonSave
|
||||||
|
//
|
||||||
|
ButtonSave.Location = new Point(94, 225);
|
||||||
|
ButtonSave.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
ButtonSave.Name = "ButtonSave";
|
||||||
|
ButtonSave.Size = new Size(111, 39);
|
||||||
|
ButtonSave.TabIndex = 9;
|
||||||
|
ButtonSave.Text = "Сохранить";
|
||||||
|
ButtonSave.UseVisualStyleBackColor = true;
|
||||||
|
ButtonSave.Click += ButtonSave_Click;
|
||||||
|
//
|
||||||
|
// FormImplementer
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(350, 285);
|
||||||
|
Controls.Add(ButtonSave);
|
||||||
|
Controls.Add(ButtonCancel);
|
||||||
|
Controls.Add(LabelQualification);
|
||||||
|
Controls.Add(LabelWorkExperience);
|
||||||
|
Controls.Add(WorkExpNumericUpDown);
|
||||||
|
Controls.Add(QualificationNumericUpDown);
|
||||||
|
Controls.Add(LabelPassword);
|
||||||
|
Controls.Add(LabelFIO);
|
||||||
|
Controls.Add(PasswordTextBox);
|
||||||
|
Controls.Add(FIOTextBox);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormImplementer";
|
||||||
|
Text = "Исполнитель";
|
||||||
|
Load += FormImplementer_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)QualificationNumericUpDown).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)WorkExpNumericUpDown).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox FIOTextBox;
|
||||||
|
private TextBox PasswordTextBox;
|
||||||
|
private Label LabelFIO;
|
||||||
|
private Label LabelPassword;
|
||||||
|
private NumericUpDown QualificationNumericUpDown;
|
||||||
|
private NumericUpDown WorkExpNumericUpDown;
|
||||||
|
private Label LabelWorkExperience;
|
||||||
|
private Label LabelQualification;
|
||||||
|
private Button ButtonCancel;
|
||||||
|
private Button ButtonSave;
|
||||||
|
}
|
||||||
|
}
|
106
PlumbingRepair/PlumbingRepair/FormImplementer.cs
Normal file
106
PlumbingRepair/PlumbingRepair/FormImplementer.cs
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||||
|
using PlumbingRepairContracts.SearchModels;
|
||||||
|
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 PlumbingRepair
|
||||||
|
{
|
||||||
|
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<FormImplementer> logger, IImplementerLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(PasswordTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните пароль", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(FIOTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните фио", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Сохранение исполнителя");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ImplementerBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
ImplementerFIO = FIOTextBox.Text,
|
||||||
|
Password = PasswordTextBox.Text,
|
||||||
|
Qualification = (int)QualificationNumericUpDown.Value,
|
||||||
|
WorkExperience = (int)WorkExpNumericUpDown.Value,
|
||||||
|
};
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormImplementer_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение исполнителя");
|
||||||
|
var view = _logic.ReadElement(new ImplementerSearchModel
|
||||||
|
{
|
||||||
|
Id = _id.Value
|
||||||
|
});
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
FIOTextBox.Text = view.ImplementerFIO;
|
||||||
|
PasswordTextBox.Text = view.Password;
|
||||||
|
QualificationNumericUpDown.Value = view.Qualification;
|
||||||
|
WorkExpNumericUpDown.Value = view.WorkExperience;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения исполнителя");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
PlumbingRepair/PlumbingRepair/FormImplementer.resx
Normal file
120
PlumbingRepair/PlumbingRepair/FormImplementer.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
114
PlumbingRepair/PlumbingRepair/FormImplementers.Designer.cs
generated
Normal file
114
PlumbingRepair/PlumbingRepair/FormImplementers.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
namespace PlumbingRepair
|
||||||
|
{
|
||||||
|
partial class FormImplementers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.AddButton = new System.Windows.Forms.Button();
|
||||||
|
this.ChangeButton = new System.Windows.Forms.Button();
|
||||||
|
this.DeleteButton = new System.Windows.Forms.Button();
|
||||||
|
this.UpdateButton = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// DataGridView
|
||||||
|
//
|
||||||
|
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.DataGridView.Location = new System.Drawing.Point(1, 1);
|
||||||
|
this.DataGridView.Name = "DataGridView";
|
||||||
|
this.DataGridView.RowTemplate.Height = 25;
|
||||||
|
this.DataGridView.Size = new System.Drawing.Size(632, 448);
|
||||||
|
this.DataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// AddButton
|
||||||
|
//
|
||||||
|
this.AddButton.Location = new System.Drawing.Point(639, 12);
|
||||||
|
this.AddButton.Name = "AddButton";
|
||||||
|
this.AddButton.Size = new System.Drawing.Size(98, 45);
|
||||||
|
this.AddButton.TabIndex = 1;
|
||||||
|
this.AddButton.Text = "Добавить";
|
||||||
|
this.AddButton.UseVisualStyleBackColor = true;
|
||||||
|
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
||||||
|
//
|
||||||
|
// ChangeButton
|
||||||
|
//
|
||||||
|
this.ChangeButton.Location = new System.Drawing.Point(639, 63);
|
||||||
|
this.ChangeButton.Name = "ChangeButton";
|
||||||
|
this.ChangeButton.Size = new System.Drawing.Size(98, 45);
|
||||||
|
this.ChangeButton.TabIndex = 2;
|
||||||
|
this.ChangeButton.Text = "Изменить";
|
||||||
|
this.ChangeButton.UseVisualStyleBackColor = true;
|
||||||
|
this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
|
||||||
|
//
|
||||||
|
// DeleteButton
|
||||||
|
//
|
||||||
|
this.DeleteButton.Location = new System.Drawing.Point(639, 114);
|
||||||
|
this.DeleteButton.Name = "DeleteButton";
|
||||||
|
this.DeleteButton.Size = new System.Drawing.Size(98, 45);
|
||||||
|
this.DeleteButton.TabIndex = 3;
|
||||||
|
this.DeleteButton.Text = "Удалить";
|
||||||
|
this.DeleteButton.UseVisualStyleBackColor = true;
|
||||||
|
this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
|
||||||
|
//
|
||||||
|
// UpdateButton
|
||||||
|
//
|
||||||
|
this.UpdateButton.Location = new System.Drawing.Point(639, 165);
|
||||||
|
this.UpdateButton.Name = "UpdateButton";
|
||||||
|
this.UpdateButton.Size = new System.Drawing.Size(98, 45);
|
||||||
|
this.UpdateButton.TabIndex = 4;
|
||||||
|
this.UpdateButton.Text = "Обновить";
|
||||||
|
this.UpdateButton.UseVisualStyleBackColor = true;
|
||||||
|
this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
|
||||||
|
//
|
||||||
|
// FormImplementers
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(749, 450);
|
||||||
|
this.Controls.Add(this.UpdateButton);
|
||||||
|
this.Controls.Add(this.DeleteButton);
|
||||||
|
this.Controls.Add(this.ChangeButton);
|
||||||
|
this.Controls.Add(this.AddButton);
|
||||||
|
this.Controls.Add(this.DataGridView);
|
||||||
|
this.Name = "FormImplementers";
|
||||||
|
this.Text = "Исполнители";
|
||||||
|
this.Load += new System.EventHandler(this.FormImplementers_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView DataGridView;
|
||||||
|
private Button AddButton;
|
||||||
|
private Button ChangeButton;
|
||||||
|
private Button DeleteButton;
|
||||||
|
private Button UpdateButton;
|
||||||
|
}
|
||||||
|
}
|
121
PlumbingRepair/PlumbingRepair/FormImplementers.cs
Normal file
121
PlumbingRepair/PlumbingRepair/FormImplementers.cs
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||||
|
using PlumbingRepairView;
|
||||||
|
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 PlumbingRepair
|
||||||
|
{
|
||||||
|
public partial class FormImplementers : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IImplementerLogic _logic;
|
||||||
|
public FormImplementers(ILogger<FormImplementers> logger, IImplementerLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddButton_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 ChangeButton_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 DeleteButton_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 UpdateButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormImplementers_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
PlumbingRepair/PlumbingRepair/FormImplementers.resx
Normal file
120
PlumbingRepair/PlumbingRepair/FormImplementers.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
168
PlumbingRepair/PlumbingRepair/FormMain.Designer.cs
generated
168
PlumbingRepair/PlumbingRepair/FormMain.Designer.cs
generated
@ -1,42 +1,44 @@
|
|||||||
namespace PlumbingRepairView
|
namespace PlumbingRepairView
|
||||||
{
|
{
|
||||||
partial class FormMain
|
partial class FormMain
|
||||||
{
|
{
|
||||||
/// <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()
|
||||||
{
|
{
|
||||||
menuStrip1 = new MenuStrip();
|
menuStrip1 = new MenuStrip();
|
||||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
КлиентыToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
работыToolStripMenuItem = new ToolStripMenuItem();
|
работыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
КлиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
списокКомпонентовToolStripMenuItem = new ToolStripMenuItem();
|
списокКомпонентовToolStripMenuItem = new ToolStripMenuItem();
|
||||||
компонентыПоРаботамToolStripMenuItem = new ToolStripMenuItem();
|
компонентыПоРаботамToolStripMenuItem = new ToolStripMenuItem();
|
||||||
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
исполнителиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
запускРаботToolStripMenuItem = new ToolStripMenuItem();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
buttonCreateOrder = new Button();
|
buttonCreateOrder = new Button();
|
||||||
buttonTakeOrderInWork = new Button();
|
buttonTakeOrderInWork = new Button();
|
||||||
@ -50,84 +52,101 @@
|
|||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||||
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem });
|
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem, запускРаботToolStripMenuItem });
|
||||||
menuStrip1.Location = new Point(0, 0);
|
menuStrip1.Location = new Point(0, 0);
|
||||||
menuStrip1.Name = "menuStrip1";
|
menuStrip1.Name = "menuStrip1";
|
||||||
menuStrip1.Size = new Size(1103, 28);
|
menuStrip1.Padding = new Padding(8, 2, 0, 2);
|
||||||
|
menuStrip1.Size = new Size(1379, 33);
|
||||||
menuStrip1.TabIndex = 0;
|
menuStrip1.TabIndex = 0;
|
||||||
menuStrip1.Text = "menuStrip1";
|
menuStrip1.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
// справочникиToolStripMenuItem
|
// справочникиToolStripMenuItem
|
||||||
//
|
//
|
||||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, работыToolStripMenuItem, КлиентыToolStripMenuItem });
|
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, работыToolStripMenuItem, КлиентыToolStripMenuItem, исполнителиToolStripMenuItem });
|
||||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
справочникиToolStripMenuItem.Size = new Size(139, 29);
|
||||||
справочникиToolStripMenuItem.Text = "Справочники";
|
справочникиToolStripMenuItem.Text = "Справочники";
|
||||||
//
|
//
|
||||||
// компонентыToolStripMenuItem
|
// компонентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||||
компонентыToolStripMenuItem.Size = new Size(182, 26);
|
компонентыToolStripMenuItem.Size = new Size(270, 34);
|
||||||
компонентыToolStripMenuItem.Text = "Компоненты";
|
компонентыToolStripMenuItem.Text = "Компоненты";
|
||||||
компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click;
|
компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// работыToolStripMenuItem
|
||||||
|
//
|
||||||
|
работыToolStripMenuItem.Name = "работыToolStripMenuItem";
|
||||||
|
работыToolStripMenuItem.Size = new Size(270, 34);
|
||||||
|
работыToolStripMenuItem.Text = "Работы";
|
||||||
|
работыToolStripMenuItem.Click += работыToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// КлиентыToolStripMenuItem
|
// КлиентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
КлиентыToolStripMenuItem.Name = "КлиентыToolStripMenuItem";
|
КлиентыToolStripMenuItem.Name = "КлиентыToolStripMenuItem";
|
||||||
КлиентыToolStripMenuItem.Size = new Size(182, 26);
|
КлиентыToolStripMenuItem.Size = new Size(270, 34);
|
||||||
КлиентыToolStripMenuItem.Text = "Клиенты";
|
КлиентыToolStripMenuItem.Text = "Клиенты";
|
||||||
КлиентыToolStripMenuItem.Click += КлиентыToolStripMenuItem_Click;
|
КлиентыToolStripMenuItem.Click += КлиентыToolStripMenuItem_Click;
|
||||||
//
|
|
||||||
// работыToolStripMenuItem
|
|
||||||
//
|
|
||||||
работыToolStripMenuItem.Name = "работыToolStripMenuItem";
|
|
||||||
работыToolStripMenuItem.Size = new Size(182, 26);
|
|
||||||
работыToolStripMenuItem.Text = "Работы";
|
|
||||||
работыToolStripMenuItem.Click += работыToolStripMenuItem_Click;
|
|
||||||
//
|
//
|
||||||
// отчётыToolStripMenuItem
|
// отчётыToolStripMenuItem
|
||||||
//
|
//
|
||||||
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоРаботамToolStripMenuItem, списокЗаказовToolStripMenuItem });
|
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоРаботамToolStripMenuItem, списокЗаказовToolStripMenuItem });
|
||||||
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||||
отчётыToolStripMenuItem.Size = new Size(73, 24);
|
отчётыToolStripMenuItem.Size = new Size(88, 29);
|
||||||
отчётыToolStripMenuItem.Text = "Отчёты";
|
отчётыToolStripMenuItem.Text = "Отчёты";
|
||||||
//
|
//
|
||||||
// списокКомпонентовToolStripMenuItem
|
// списокКомпонентовToolStripMenuItem
|
||||||
//
|
//
|
||||||
списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
|
списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
|
||||||
списокКомпонентовToolStripMenuItem.Size = new Size(268, 26);
|
списокКомпонентовToolStripMenuItem.Size = new Size(319, 34);
|
||||||
списокКомпонентовToolStripMenuItem.Text = "Список работ";
|
списокКомпонентовToolStripMenuItem.Text = "Список работ";
|
||||||
списокКомпонентовToolStripMenuItem.Click += списокРаботToolStripMenuItem_Click;
|
списокКомпонентовToolStripMenuItem.Click += списокРаботToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// компонентыПоРаботамToolStripMenuItem
|
// компонентыПоРаботамToolStripMenuItem
|
||||||
//
|
//
|
||||||
компонентыПоРаботамToolStripMenuItem.Name = "компонентыПоРаботамToolStripMenuItem";
|
компонентыПоРаботамToolStripMenuItem.Name = "компонентыПоРаботамToolStripMenuItem";
|
||||||
компонентыПоРаботамToolStripMenuItem.Size = new Size(268, 26);
|
компонентыПоРаботамToolStripMenuItem.Size = new Size(319, 34);
|
||||||
компонентыПоРаботамToolStripMenuItem.Text = "Компоненты по работам";
|
компонентыПоРаботамToolStripMenuItem.Text = "Компоненты по работам";
|
||||||
компонентыПоРаботамToolStripMenuItem.Click += компонентыПоРаботамToolStripMenuItem_Click;
|
компонентыПоРаботамToolStripMenuItem.Click += компонентыПоРаботамToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// списокЗаказовToolStripMenuItem
|
// списокЗаказовToolStripMenuItem
|
||||||
//
|
//
|
||||||
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
|
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
|
||||||
списокЗаказовToolStripMenuItem.Size = new Size(268, 26);
|
списокЗаказовToolStripMenuItem.Size = new Size(319, 34);
|
||||||
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||||
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
|
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// исполнителиToolStripMenuItem
|
||||||
|
//
|
||||||
|
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||||
|
исполнителиToolStripMenuItem.Size = new Size(185, 26);
|
||||||
|
исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||||
|
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// запускРаботToolStripMenuItem
|
||||||
|
//
|
||||||
|
запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
|
||||||
|
запускРаботToolStripMenuItem.Size = new Size(114, 24);
|
||||||
|
запускРаботToolStripMenuItem.Text = "Запуск работ";
|
||||||
|
запускРаботToolStripMenuItem.Click += запускРаботToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Location = new Point(0, 31);
|
dataGridView.Location = new Point(0, 39);
|
||||||
|
dataGridView.Margin = new Padding(4);
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.RowHeadersWidth = 51;
|
dataGridView.RowHeadersWidth = 51;
|
||||||
dataGridView.RowTemplate.Height = 29;
|
dataGridView.RowTemplate.Height = 29;
|
||||||
dataGridView.Size = new Size(878, 420);
|
dataGridView.Size = new Size(1098, 525);
|
||||||
dataGridView.TabIndex = 1;
|
dataGridView.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// buttonCreateOrder
|
// buttonCreateOrder
|
||||||
//
|
//
|
||||||
buttonCreateOrder.Location = new Point(903, 54);
|
buttonCreateOrder.Location = new Point(1129, 68);
|
||||||
|
buttonCreateOrder.Margin = new Padding(4);
|
||||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||||
buttonCreateOrder.Size = new Size(170, 29);
|
buttonCreateOrder.Size = new Size(212, 36);
|
||||||
buttonCreateOrder.TabIndex = 2;
|
buttonCreateOrder.TabIndex = 2;
|
||||||
buttonCreateOrder.Text = "Создать заказ";
|
buttonCreateOrder.Text = "Создать заказ";
|
||||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||||
@ -135,9 +154,10 @@
|
|||||||
//
|
//
|
||||||
// buttonTakeOrderInWork
|
// buttonTakeOrderInWork
|
||||||
//
|
//
|
||||||
buttonTakeOrderInWork.Location = new Point(903, 142);
|
buttonTakeOrderInWork.Location = new Point(1129, 178);
|
||||||
|
buttonTakeOrderInWork.Margin = new Padding(4);
|
||||||
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||||
buttonTakeOrderInWork.Size = new Size(170, 50);
|
buttonTakeOrderInWork.Size = new Size(212, 62);
|
||||||
buttonTakeOrderInWork.TabIndex = 3;
|
buttonTakeOrderInWork.TabIndex = 3;
|
||||||
buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||||
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||||
@ -145,9 +165,10 @@
|
|||||||
//
|
//
|
||||||
// buttonOrderReady
|
// buttonOrderReady
|
||||||
//
|
//
|
||||||
buttonOrderReady.Location = new Point(903, 233);
|
buttonOrderReady.Location = new Point(1129, 291);
|
||||||
|
buttonOrderReady.Margin = new Padding(4);
|
||||||
buttonOrderReady.Name = "buttonOrderReady";
|
buttonOrderReady.Name = "buttonOrderReady";
|
||||||
buttonOrderReady.Size = new Size(170, 29);
|
buttonOrderReady.Size = new Size(212, 36);
|
||||||
buttonOrderReady.TabIndex = 4;
|
buttonOrderReady.TabIndex = 4;
|
||||||
buttonOrderReady.Text = "Заказ готов";
|
buttonOrderReady.Text = "Заказ готов";
|
||||||
buttonOrderReady.UseVisualStyleBackColor = true;
|
buttonOrderReady.UseVisualStyleBackColor = true;
|
||||||
@ -155,9 +176,10 @@
|
|||||||
//
|
//
|
||||||
// buttonIssuedOrder
|
// buttonIssuedOrder
|
||||||
//
|
//
|
||||||
buttonIssuedOrder.Location = new Point(903, 323);
|
buttonIssuedOrder.Location = new Point(1129, 404);
|
||||||
|
buttonIssuedOrder.Margin = new Padding(4);
|
||||||
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||||
buttonIssuedOrder.Size = new Size(170, 29);
|
buttonIssuedOrder.Size = new Size(212, 36);
|
||||||
buttonIssuedOrder.TabIndex = 5;
|
buttonIssuedOrder.TabIndex = 5;
|
||||||
buttonIssuedOrder.Text = "Заказ выдан";
|
buttonIssuedOrder.Text = "Заказ выдан";
|
||||||
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||||
@ -165,9 +187,10 @@
|
|||||||
//
|
//
|
||||||
// buttonUpdateList
|
// buttonUpdateList
|
||||||
//
|
//
|
||||||
buttonUpdateList.Location = new Point(903, 394);
|
buttonUpdateList.Location = new Point(1129, 492);
|
||||||
|
buttonUpdateList.Margin = new Padding(4);
|
||||||
buttonUpdateList.Name = "buttonUpdateList";
|
buttonUpdateList.Name = "buttonUpdateList";
|
||||||
buttonUpdateList.Size = new Size(170, 29);
|
buttonUpdateList.Size = new Size(212, 36);
|
||||||
buttonUpdateList.TabIndex = 6;
|
buttonUpdateList.TabIndex = 6;
|
||||||
buttonUpdateList.Text = "Обновить список";
|
buttonUpdateList.Text = "Обновить список";
|
||||||
buttonUpdateList.UseVisualStyleBackColor = true;
|
buttonUpdateList.UseVisualStyleBackColor = true;
|
||||||
@ -175,9 +198,9 @@
|
|||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(1103, 474);
|
ClientSize = new Size(1379, 592);
|
||||||
Controls.Add(buttonUpdateList);
|
Controls.Add(buttonUpdateList);
|
||||||
Controls.Add(buttonIssuedOrder);
|
Controls.Add(buttonIssuedOrder);
|
||||||
Controls.Add(buttonOrderReady);
|
Controls.Add(buttonOrderReady);
|
||||||
@ -186,6 +209,7 @@
|
|||||||
Controls.Add(dataGridView);
|
Controls.Add(dataGridView);
|
||||||
Controls.Add(menuStrip1);
|
Controls.Add(menuStrip1);
|
||||||
MainMenuStrip = menuStrip1;
|
MainMenuStrip = menuStrip1;
|
||||||
|
Margin = new Padding(4);
|
||||||
Name = "FormMain";
|
Name = "FormMain";
|
||||||
Text = "Ремонт сантехники";
|
Text = "Ремонт сантехники";
|
||||||
Load += FormMain_Load;
|
Load += FormMain_Load;
|
||||||
@ -196,22 +220,24 @@
|
|||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private MenuStrip menuStrip1;
|
private MenuStrip menuStrip1;
|
||||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
private Button buttonCreateOrder;
|
private Button buttonCreateOrder;
|
||||||
private Button buttonTakeOrderInWork;
|
private Button buttonTakeOrderInWork;
|
||||||
private Button buttonOrderReady;
|
private Button buttonOrderReady;
|
||||||
private Button buttonIssuedOrder;
|
private Button buttonIssuedOrder;
|
||||||
private Button buttonUpdateList;
|
private Button buttonUpdateList;
|
||||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
private ToolStripMenuItem компонентыToolStripMenuItem;
|
||||||
private ToolStripMenuItem работыToolStripMenuItem;
|
private ToolStripMenuItem работыToolStripMenuItem;
|
||||||
private ToolStripMenuItem отчётыToolStripMenuItem;
|
private ToolStripMenuItem отчётыToolStripMenuItem;
|
||||||
private ToolStripMenuItem списокКомпонентовToolStripMenuItem;
|
private ToolStripMenuItem списокКомпонентовToolStripMenuItem;
|
||||||
private ToolStripMenuItem компонентыПоРаботамToolStripMenuItem;
|
private ToolStripMenuItem компонентыПоРаботамToolStripMenuItem;
|
||||||
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
|
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||||
private ToolStripMenuItem КлиентыToolStripMenuItem;
|
private ToolStripMenuItem КлиентыToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PlumbingRepair;
|
||||||
using PlumbingRepairBusinessLogic.BusinessLogics;
|
using PlumbingRepairBusinessLogic.BusinessLogics;
|
||||||
using PlumbingRepairContracts.BindingModels;
|
using PlumbingRepairContracts.BindingModels;
|
||||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||||
@ -20,13 +21,15 @@ namespace PlumbingRepairView
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderLogic _orderLogic;
|
private readonly IOrderLogic _orderLogic;
|
||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
|
private readonly IWorkProcess _workProcess;
|
||||||
|
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
|
_workProcess = workProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
@ -46,7 +49,8 @@ namespace PlumbingRepairView
|
|||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["WorkId"].Visible = false;
|
dataGridView.Columns["WorkId"].Visible = false;
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
dataGridView.Columns["ClientId"].Visible = false;
|
||||||
}
|
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
@ -240,5 +244,20 @@ namespace PlumbingRepairView
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
||||||
|
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
||||||
|
|
||||||
|
if (service is FormImplementers form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -9,6 +9,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
using PlumbingRepairBusinessLogic.BusinessLogics;
|
using PlumbingRepairBusinessLogic.BusinessLogics;
|
||||||
|
using PlumbingRepair;
|
||||||
|
|
||||||
namespace PlumbingRepairView
|
namespace PlumbingRepairView
|
||||||
{
|
{
|
||||||
@ -41,12 +42,15 @@ namespace PlumbingRepairView
|
|||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
services.AddTransient<IWorkStorage, WorkStorage>();
|
services.AddTransient<IWorkStorage, WorkStorage>();
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
|
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
|
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<IWorkLogic, WorkLogic>();
|
services.AddTransient<IWorkLogic, WorkLogic>();
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
|
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
|
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||||
|
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||||
@ -62,6 +66,8 @@ namespace PlumbingRepairView
|
|||||||
services.AddTransient<FormReportWorkComponents>();
|
services.AddTransient<FormReportWorkComponents>();
|
||||||
services.AddTransient<FormReportOrders>();
|
services.AddTransient<FormReportOrders>();
|
||||||
services.AddTransient<FormClients>();
|
services.AddTransient<FormClients>();
|
||||||
}
|
services.AddTransient<FormImplementer>();
|
||||||
|
services.AddTransient<FormImplementers>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
15
PlumbingRepair/PlumbingRepair/nlog.config
Normal file
15
PlumbingRepair/PlumbingRepair/nlog.config
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
autoReload="true" internalLogLevel="Info">
|
||||||
|
|
||||||
|
<targets>
|
||||||
|
<target xsi:type="File" name="tofile" fileName="${basedir}/carlog-${shortdate}.log" />
|
||||||
|
</targets>
|
||||||
|
|
||||||
|
<rules>
|
||||||
|
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
||||||
|
</rules>
|
||||||
|
</nlog>
|
||||||
|
</configuration>
|
@ -0,0 +1,130 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||||
|
using PlumbingRepairContracts.SearchModels;
|
||||||
|
using PlumbingRepairContracts.StoragesContracts;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ImplementerLogic : IImplementerLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IImplementerStorage _implementerStorage;
|
||||||
|
|
||||||
|
public ImplementerLogic(ILogger<ImplementerLogic> logger, IImplementerStorage implementerStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_implementerStorage = implementerStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_implementerStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. FIO:{FIO}.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 List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. FIO:{FIO}.Id:{ Id} ", model?.ImplementerFIO, model?.Id);
|
||||||
|
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 bool Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_implementerStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(ImplementerBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (model.WorkExperience < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Опыт работы не должен быть отрицательным", nameof(model.WorkExperience));
|
||||||
|
}
|
||||||
|
if (model.Qualification < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Квалификация не должна быть отрицательной", nameof(model.Qualification));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет пароля исполнителя", nameof(model.ImplementerFIO));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет ФИО исполнителя", nameof(model.ImplementerFIO));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Implementer. Id: {Id}, FIO: {FIO}", model.Id, model.ImplementerFIO);
|
||||||
|
var element = _implementerStorage.GetElement(new ImplementerSearchModel
|
||||||
|
{
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Исполнитель с таким ФИО уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -74,25 +74,39 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||||
if (model.Status + 1 != newStatus)
|
if (viewModel == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (viewModel.Status + 1 != newStatus)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
model.Status = newStatus;
|
model.Status = newStatus;
|
||||||
|
model.DateCreate = viewModel.DateCreate;
|
||||||
|
model.Sum = viewModel.Sum;
|
||||||
|
model.Count = viewModel.Count;
|
||||||
|
model.DateImplement = viewModel.DateImplement;
|
||||||
|
model.WorkId = viewModel.WorkId;
|
||||||
|
|
||||||
if (model.Status == OrderStatus.Выдан)
|
if (viewModel.ImplementerId.HasValue)
|
||||||
model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
{
|
||||||
|
model.ImplementerId = viewModel.ImplementerId;
|
||||||
|
}
|
||||||
|
if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model.DateImplement = viewModel.DateImplement;
|
||||||
|
}
|
||||||
|
CheckModel(model);
|
||||||
if (_orderStorage.Update(model) == null)
|
if (_orderStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
model.Status--;
|
model.Status--;
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
public bool TakeOrderInWork(OrderBindingModel model)
|
||||||
@ -102,12 +116,12 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
public bool DeliveryOrder(OrderBindingModel model)
|
public bool DeliveryOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
return StatusUpdate(model, OrderStatus.Готов);
|
return StatusUpdate(model, OrderStatus.Выдан);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
public bool FinishOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
return StatusUpdate(model, OrderStatus.Выдан);
|
return StatusUpdate(model, OrderStatus.Готов);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||||
|
@ -0,0 +1,150 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||||
|
using PlumbingRepairContracts.SearchModels;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using PlumbingRepairDataModels.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class WorkModeling : IWorkProcess
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly Random _rnd;
|
||||||
|
|
||||||
|
private IOrderLogic? _orderLogic;
|
||||||
|
|
||||||
|
public WorkModeling(ILogger<WorkModeling> 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 OrderSearchModel { Status = OrderStatus.Принят });
|
||||||
|
if (orders == null || orders.Count == 0)
|
||||||
|
{
|
||||||
|
_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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Иммитация работы исполнителя
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="implementer"></param>
|
||||||
|
/// <param name="orders"></param>
|
||||||
|
private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders)
|
||||||
|
{
|
||||||
|
if (_orderLogic == null || implementer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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 * _rnd.Next(100, 1000) * 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 * _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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="implementer"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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 * _rnd.Next(100, 300) * 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 * _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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using PlumbingRepairDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairContracts.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; }
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,7 @@ namespace PlumbingRepairContracts.BindingModels
|
|||||||
public int WorkId { get; set; }
|
public int WorkId { get; set; }
|
||||||
public String WorkName { get; set; } = string.Empty;
|
public String WorkName { get; set; } = string.Empty;
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
public int? ImplementerId { get; set; }
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.SearchModels;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IImplementerLogic
|
||||||
|
{
|
||||||
|
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
|
||||||
|
|
||||||
|
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
|
||||||
|
|
||||||
|
bool Create(ImplementerBindingModel model);
|
||||||
|
|
||||||
|
bool Update(ImplementerBindingModel model);
|
||||||
|
|
||||||
|
bool Delete(ImplementerBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@ namespace PlumbingRepairContracts.BusinessLogicsContracts
|
|||||||
public interface IOrderLogic
|
public interface IOrderLogic
|
||||||
{
|
{
|
||||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||||
|
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||||
bool CreateOrder(OrderBindingModel model);
|
bool CreateOrder(OrderBindingModel model);
|
||||||
bool TakeOrderInWork(OrderBindingModel model);
|
bool TakeOrderInWork(OrderBindingModel model);
|
||||||
bool FinishOrder(OrderBindingModel model);
|
bool FinishOrder(OrderBindingModel model);
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IWorkProcess
|
||||||
|
{
|
||||||
|
void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class ImplementerSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? ImplementerFIO { get; set; }
|
||||||
|
public string? Password { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using PlumbingRepairDataModels.Enums;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -12,5 +13,7 @@ namespace PlumbingRepairContracts.SearchModels
|
|||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
|
public int? ImplementerId { get; set; }
|
||||||
|
public OrderStatus? Status { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.SearchModels;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IImplementerStorage
|
||||||
|
{
|
||||||
|
List<ImplementerViewModel> GetFullList();
|
||||||
|
List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model);
|
||||||
|
ImplementerViewModel? GetElement(ImplementerSearchModel model);
|
||||||
|
ImplementerViewModel? Insert(ImplementerBindingModel model);
|
||||||
|
ImplementerViewModel? Update(ImplementerBindingModel model);
|
||||||
|
ImplementerViewModel? Delete(ImplementerBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
using PlumbingRepairDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairContracts.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; }
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,9 @@ namespace PlumbingRepairContracts.ViewModels
|
|||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
[DisplayName("ФИО клиента")]
|
[DisplayName("ФИО клиента")]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
public int? ImplementerId { get; set; }
|
||||||
|
[DisplayName("Исполнитель")]
|
||||||
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[DisplayName("Сумма")]
|
[DisplayName("Сумма")]
|
||||||
|
@ -0,0 +1,101 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.SearchModels;
|
||||||
|
using PlumbingRepairContracts.StoragesContracts;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using PlumbingRepairDataBaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairDataBaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ImplementerStorage : IImplementerStorage
|
||||||
|
{
|
||||||
|
public ImplementerViewModel? Delete(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new PlumbingRepairDataBase();
|
||||||
|
var element = context.Implementers
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Implementers.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO) &&
|
||||||
|
string.IsNullOrEmpty(model.Password) &&
|
||||||
|
!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new PlumbingRepairDataBase();
|
||||||
|
return context.Implementers
|
||||||
|
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ImplementerFIO) || x.ImplementerFIO == model.ImplementerFIO) &&
|
||||||
|
(string.IsNullOrEmpty(model.Password) || x.Password == model.Password) &&
|
||||||
|
(!model.Id.HasValue || x.Id == model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(model.ImplementerFIO))
|
||||||
|
{
|
||||||
|
using var context = new PlumbingRepairDataBase();
|
||||||
|
return context.Implementers
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new PlumbingRepairDataBase();
|
||||||
|
return context.Implementers
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Insert(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
var newImplementer = Implementer.Create(model);
|
||||||
|
if (newImplementer == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new PlumbingRepairDataBase();
|
||||||
|
context.Implementers.Add(newImplementer);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newImplementer.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new PlumbingRepairDataBase();
|
||||||
|
var client = context.Implementers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
client.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return client.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,8 @@ namespace PlumbingRepairDataBaseImplement.Implements
|
|||||||
|
|
||||||
return context.Orders.Include(x => x.Work)
|
return context.Orders.Include(x => x.Work)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.Select(x => x.GetViewModel)
|
.Include(x => x.Implementer)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +33,8 @@ namespace PlumbingRepairDataBaseImplement.Implements
|
|||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Work)
|
.Include(x => x.Work)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.Where(x => x.Id == model.Id)
|
.Include(x => x.Implementer)
|
||||||
|
.Where(x => x.Id == model.Id)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -41,7 +43,8 @@ namespace PlumbingRepairDataBaseImplement.Implements
|
|||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Work)
|
.Include(x => x.Work)
|
||||||
.Include(x => x.Client)
|
.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)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -50,13 +53,29 @@ namespace PlumbingRepairDataBaseImplement.Implements
|
|||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Work)
|
.Include(x => x.Work)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.Where(x => x.ClientId == model.ClientId)
|
.Include(x => x.Implementer)
|
||||||
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
else if (model.ImplementerId.HasValue)
|
||||||
return new();
|
{
|
||||||
}
|
return context.Orders
|
||||||
|
.Include(x => x.Work)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Include(x => x.Implementer)
|
||||||
|
.Where(x => x.ImplementerId == model.ImplementerId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
return context.Orders
|
||||||
|
.Include(x => x.Work)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Include(x => x.Implementer)
|
||||||
|
.Where(x => model.Status == x.Status)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
@ -70,8 +89,10 @@ namespace PlumbingRepairDataBaseImplement.Implements
|
|||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Work)
|
.Include(x => x.Work)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
.Include(x => x.Implementer)
|
||||||
?.GetViewModel;
|
.FirstOrDefault(x => (!model.ImplementerId.HasValue || x.ImplementerId == model.ImplementerId) &&
|
||||||
|
(!model.Status.HasValue || x.Status == model.Status) &&
|
||||||
|
(!model.Id.HasValue || x.Id == model.Id))?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
@ -91,7 +112,8 @@ namespace PlumbingRepairDataBaseImplement.Implements
|
|||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Work)
|
.Include(x => x.Work)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.FirstOrDefault(x => x.Id == newOrder.Id)
|
.Include(x => x.Implementer)
|
||||||
|
.FirstOrDefault(x => x.Id == newOrder.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +134,8 @@ namespace PlumbingRepairDataBaseImplement.Implements
|
|||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Work)
|
.Include(x => x.Work)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.FirstOrDefault(x => x.Id == model.Id)
|
.Include(x => x.Implementer)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,6 +150,7 @@ namespace PlumbingRepairDataBaseImplement.Implements
|
|||||||
var deletedElement = context.Orders
|
var deletedElement = context.Orders
|
||||||
.Include(x => x.Work)
|
.Include(x => x.Work)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
|
.Include(x => x.Implementer)
|
||||||
.FirstOrDefault(x => x.Id == model.Id)
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
context.Orders.Remove(element);
|
context.Orders.Remove(element);
|
||||||
|
@ -1,218 +1,261 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using PlumbingRepairDataBaseImplement;
|
using PlumbingRepairDataBaseImplement;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace PlumbingRepairDataBaseImplement.Migrations
|
namespace PlumbingRepairDataBaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(PlumbingRepairDataBase))]
|
[DbContext(typeof(PlumbingRepairDataBase))]
|
||||||
[Migration("20240424045110_MigrationWithClient")]
|
[Migration("20240503161017_WithImplementers")]
|
||||||
partial class MigrationWithClient
|
partial class WithImplementers
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "7.0.17")
|
.HasAnnotation("ProductVersion", "7.0.17")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Client", b =>
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Client", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("ClientFIO")
|
b.Property<string>("ClientFIO")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("Email")
|
b.Property<string>("Email")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("Password")
|
b.Property<string>("Password")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Clients");
|
b.ToTable("Clients");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Component", b =>
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Component", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("ComponentName")
|
b.Property<string>("ComponentName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
b.Property<double>("Cost")
|
||||||
.HasColumnType("double precision");
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Components");
|
b.ToTable("Components");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Order", b =>
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Implementer", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("ClientId")
|
b.Property<string>("ImplementerFIO")
|
||||||
.HasColumnType("integer");
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("integer");
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
b.Property<DateTime>("DateCreate")
|
.HasColumnType("text");
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
b.Property<DateTime?>("DateImplement")
|
.HasColumnType("integer");
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
b.Property<int>("Status")
|
.HasColumnType("integer");
|
||||||
.HasColumnType("integer");
|
|
||||||
|
b.HasKey("Id");
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("double precision");
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
b.Property<int>("WorkId")
|
|
||||||
.HasColumnType("integer");
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
b.Property<string>("WorkName")
|
b.Property<int>("Id")
|
||||||
.IsRequired()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("text");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.HasKey("Id");
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.HasIndex("ClientId");
|
b.Property<int>("ClientId")
|
||||||
|
.HasColumnType("integer");
|
||||||
b.HasIndex("WorkId");
|
|
||||||
|
b.Property<int>("Count")
|
||||||
b.ToTable("Orders");
|
.HasColumnType("integer");
|
||||||
});
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Work", b =>
|
.HasColumnType("timestamp with time zone");
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
b.Property<DateTime?>("DateImplement")
|
||||||
.ValueGeneratedOnAdd()
|
.HasColumnType("timestamp with time zone");
|
||||||
.HasColumnType("integer");
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<double>("Price")
|
b.Property<int>("Status")
|
||||||
.HasColumnType("double precision");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<string>("WorkName")
|
b.Property<double>("Sum")
|
||||||
.IsRequired()
|
.HasColumnType("double precision");
|
||||||
.HasColumnType("text");
|
|
||||||
|
b.Property<int>("WorkId")
|
||||||
b.HasKey("Id");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.ToTable("Works");
|
b.Property<string>("WorkName")
|
||||||
});
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.WorkComponent", b =>
|
|
||||||
{
|
b.HasKey("Id");
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
b.HasIndex("ClientId");
|
||||||
.HasColumnType("integer");
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
b.HasIndex("WorkId");
|
||||||
b.Property<int>("ComponentId")
|
|
||||||
.HasColumnType("integer");
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("integer");
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
b.Property<int>("WorkId")
|
b.Property<int>("Id")
|
||||||
.HasColumnType("integer");
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
b.HasKey("Id");
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
b.HasIndex("ComponentId");
|
|
||||||
|
b.Property<double>("Price")
|
||||||
b.HasIndex("WorkId");
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
b.ToTable("WorkComponents");
|
b.Property<string>("WorkName")
|
||||||
});
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Order", b =>
|
|
||||||
{
|
b.HasKey("Id");
|
||||||
b.HasOne("PlumbingRepairDataBaseImplement.Models.Client", "Client")
|
|
||||||
.WithMany("Orders")
|
b.ToTable("Works");
|
||||||
.HasForeignKey("ClientId")
|
});
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.WorkComponent", b =>
|
||||||
|
{
|
||||||
b.HasOne("PlumbingRepairDataBaseImplement.Models.Work", "Work")
|
b.Property<int>("Id")
|
||||||
.WithMany("Orders")
|
.ValueGeneratedOnAdd()
|
||||||
.HasForeignKey("WorkId")
|
.HasColumnType("integer");
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Navigation("Client");
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
b.Navigation("Work");
|
|
||||||
});
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.WorkComponent", b =>
|
|
||||||
{
|
b.Property<int>("WorkId")
|
||||||
b.HasOne("PlumbingRepairDataBaseImplement.Models.Component", "Component")
|
.HasColumnType("integer");
|
||||||
.WithMany("WorkComponents")
|
|
||||||
.HasForeignKey("ComponentId")
|
b.HasKey("Id");
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
b.HasOne("PlumbingRepairDataBaseImplement.Models.Work", "Work")
|
b.HasIndex("WorkId");
|
||||||
.WithMany("Components")
|
|
||||||
.HasForeignKey("WorkId")
|
b.ToTable("WorkComponents");
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
});
|
||||||
.IsRequired();
|
|
||||||
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Order", b =>
|
||||||
b.Navigation("Component");
|
{
|
||||||
|
b.HasOne("PlumbingRepairDataBaseImplement.Models.Client", "Client")
|
||||||
b.Navigation("Work");
|
.WithMany("Orders")
|
||||||
});
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Client", b =>
|
.IsRequired();
|
||||||
{
|
|
||||||
b.Navigation("Orders");
|
b.HasOne("PlumbingRepairDataBaseImplement.Models.Implementer", "Implementer")
|
||||||
});
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Component", b =>
|
|
||||||
{
|
b.HasOne("PlumbingRepairDataBaseImplement.Models.Work", "Work")
|
||||||
b.Navigation("WorkComponents");
|
.WithMany("Orders")
|
||||||
});
|
.HasForeignKey("WorkId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Work", b =>
|
.IsRequired();
|
||||||
{
|
|
||||||
b.Navigation("Components");
|
b.Navigation("Client");
|
||||||
|
|
||||||
b.Navigation("Orders");
|
b.Navigation("Implementer");
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
b.Navigation("Work");
|
||||||
}
|
});
|
||||||
}
|
|
||||||
}
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.WorkComponent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("PlumbingRepairDataBaseImplement.Models.Component", "Component")
|
||||||
|
.WithMany("WorkComponents")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("PlumbingRepairDataBaseImplement.Models.Work", "Work")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("WorkId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Work");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("WorkComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,157 +1,187 @@
|
|||||||
using System;
|
using System;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace PlumbingRepairDataBaseImplement.Migrations
|
namespace PlumbingRepairDataBaseImplement.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class MigrationWithClient : Migration
|
public partial class WithImplementers : Migration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Clients",
|
name: "Clients",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
ClientFIO = table.Column<string>(type: "text", nullable: false),
|
ClientFIO = table.Column<string>(type: "text", nullable: false),
|
||||||
Email = table.Column<string>(type: "text", nullable: false),
|
Email = table.Column<string>(type: "text", nullable: false),
|
||||||
Password = table.Column<string>(type: "text", nullable: false)
|
Password = table.Column<string>(type: "text", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Components",
|
name: "Components",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
ComponentName = table.Column<string>(type: "text", nullable: false),
|
ComponentName = table.Column<string>(type: "text", nullable: false),
|
||||||
Cost = table.Column<double>(type: "double precision", nullable: false)
|
Cost = table.Column<double>(type: "double precision", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Components", x => x.Id);
|
table.PrimaryKey("PK_Components", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Works",
|
name: "Implementers",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
WorkName = table.Column<string>(type: "text", nullable: false),
|
ImplementerFIO = table.Column<string>(type: "text", nullable: false),
|
||||||
Price = table.Column<double>(type: "double precision", nullable: false)
|
Password = table.Column<string>(type: "text", nullable: false),
|
||||||
},
|
WorkExperience = table.Column<int>(type: "integer", nullable: false),
|
||||||
constraints: table =>
|
Qualification = table.Column<int>(type: "integer", nullable: false)
|
||||||
{
|
},
|
||||||
table.PrimaryKey("PK_Works", x => x.Id);
|
constraints: table =>
|
||||||
});
|
{
|
||||||
|
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||||
migrationBuilder.CreateTable(
|
});
|
||||||
name: "Orders",
|
|
||||||
columns: table => new
|
migrationBuilder.CreateTable(
|
||||||
{
|
name: "Works",
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
columns: table => new
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
{
|
||||||
WorkId = table.Column<int>(type: "integer", nullable: false),
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
ClientId = table.Column<int>(type: "integer", nullable: false),
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
WorkName = table.Column<string>(type: "text", nullable: false),
|
WorkName = table.Column<string>(type: "text", nullable: false),
|
||||||
Count = table.Column<int>(type: "integer", nullable: false),
|
Price = table.Column<double>(type: "double precision", nullable: false)
|
||||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
},
|
||||||
Status = table.Column<int>(type: "integer", nullable: false),
|
constraints: table =>
|
||||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
{
|
||||||
DateImplement = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
table.PrimaryKey("PK_Works", x => x.Id);
|
||||||
},
|
});
|
||||||
constraints: table =>
|
|
||||||
{
|
migrationBuilder.CreateTable(
|
||||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
name: "Orders",
|
||||||
table.ForeignKey(
|
columns: table => new
|
||||||
name: "FK_Orders_Clients_ClientId",
|
{
|
||||||
column: x => x.ClientId,
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
principalTable: "Clients",
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
principalColumn: "Id",
|
WorkId = table.Column<int>(type: "integer", nullable: false),
|
||||||
onDelete: ReferentialAction.Cascade);
|
ClientId = table.Column<int>(type: "integer", nullable: false),
|
||||||
table.ForeignKey(
|
ImplementerId = table.Column<int>(type: "integer", nullable: true),
|
||||||
name: "FK_Orders_Works_WorkId",
|
WorkName = table.Column<string>(type: "text", nullable: false),
|
||||||
column: x => x.WorkId,
|
Count = table.Column<int>(type: "integer", nullable: false),
|
||||||
principalTable: "Works",
|
Sum = table.Column<double>(type: "double precision", nullable: false),
|
||||||
principalColumn: "Id",
|
Status = table.Column<int>(type: "integer", nullable: false),
|
||||||
onDelete: ReferentialAction.Cascade);
|
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
});
|
DateImplement = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
||||||
|
},
|
||||||
migrationBuilder.CreateTable(
|
constraints: table =>
|
||||||
name: "WorkComponents",
|
{
|
||||||
columns: table => new
|
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||||
{
|
table.ForeignKey(
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
name: "FK_Orders_Clients_ClientId",
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
column: x => x.ClientId,
|
||||||
WorkId = table.Column<int>(type: "integer", nullable: false),
|
principalTable: "Clients",
|
||||||
ComponentId = table.Column<int>(type: "integer", nullable: false),
|
principalColumn: "Id",
|
||||||
Count = table.Column<int>(type: "integer", nullable: false)
|
onDelete: ReferentialAction.Cascade);
|
||||||
},
|
table.ForeignKey(
|
||||||
constraints: table =>
|
name: "FK_Orders_Implementers_ImplementerId",
|
||||||
{
|
column: x => x.ImplementerId,
|
||||||
table.PrimaryKey("PK_WorkComponents", x => x.Id);
|
principalTable: "Implementers",
|
||||||
table.ForeignKey(
|
principalColumn: "Id");
|
||||||
name: "FK_WorkComponents_Components_ComponentId",
|
table.ForeignKey(
|
||||||
column: x => x.ComponentId,
|
name: "FK_Orders_Works_WorkId",
|
||||||
principalTable: "Components",
|
column: x => x.WorkId,
|
||||||
principalColumn: "Id",
|
principalTable: "Works",
|
||||||
onDelete: ReferentialAction.Cascade);
|
principalColumn: "Id",
|
||||||
table.ForeignKey(
|
onDelete: ReferentialAction.Cascade);
|
||||||
name: "FK_WorkComponents_Works_WorkId",
|
});
|
||||||
column: x => x.WorkId,
|
|
||||||
principalTable: "Works",
|
migrationBuilder.CreateTable(
|
||||||
principalColumn: "Id",
|
name: "WorkComponents",
|
||||||
onDelete: ReferentialAction.Cascade);
|
columns: table => new
|
||||||
});
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
migrationBuilder.CreateIndex(
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
name: "IX_Orders_ClientId",
|
WorkId = table.Column<int>(type: "integer", nullable: false),
|
||||||
table: "Orders",
|
ComponentId = table.Column<int>(type: "integer", nullable: false),
|
||||||
column: "ClientId");
|
Count = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
migrationBuilder.CreateIndex(
|
constraints: table =>
|
||||||
name: "IX_Orders_WorkId",
|
{
|
||||||
table: "Orders",
|
table.PrimaryKey("PK_WorkComponents", x => x.Id);
|
||||||
column: "WorkId");
|
table.ForeignKey(
|
||||||
|
name: "FK_WorkComponents_Components_ComponentId",
|
||||||
migrationBuilder.CreateIndex(
|
column: x => x.ComponentId,
|
||||||
name: "IX_WorkComponents_ComponentId",
|
principalTable: "Components",
|
||||||
table: "WorkComponents",
|
principalColumn: "Id",
|
||||||
column: "ComponentId");
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
migrationBuilder.CreateIndex(
|
name: "FK_WorkComponents_Works_WorkId",
|
||||||
name: "IX_WorkComponents_WorkId",
|
column: x => x.WorkId,
|
||||||
table: "WorkComponents",
|
principalTable: "Works",
|
||||||
column: "WorkId");
|
principalColumn: "Id",
|
||||||
}
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
migrationBuilder.CreateIndex(
|
||||||
{
|
name: "IX_Orders_ClientId",
|
||||||
migrationBuilder.DropTable(
|
table: "Orders",
|
||||||
name: "Orders");
|
column: "ClientId");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.CreateIndex(
|
||||||
name: "WorkComponents");
|
name: "IX_Orders_ImplementerId",
|
||||||
|
table: "Orders",
|
||||||
migrationBuilder.DropTable(
|
column: "ImplementerId");
|
||||||
name: "Clients");
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
migrationBuilder.DropTable(
|
name: "IX_Orders_WorkId",
|
||||||
name: "Components");
|
table: "Orders",
|
||||||
|
column: "WorkId");
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Works");
|
migrationBuilder.CreateIndex(
|
||||||
}
|
name: "IX_WorkComponents_ComponentId",
|
||||||
}
|
table: "WorkComponents",
|
||||||
}
|
column: "ComponentId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_WorkComponents_WorkId",
|
||||||
|
table: "WorkComponents",
|
||||||
|
column: "WorkId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "WorkComponents");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Implementers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Components");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Works");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -67,6 +67,33 @@ namespace PlumbingRepairDataBaseImplement.Migrations
|
|||||||
b.ToTable("Components");
|
b.ToTable("Components");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Order", b =>
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -87,6 +114,9 @@ namespace PlumbingRepairDataBaseImplement.Migrations
|
|||||||
b.Property<DateTime?>("DateImplement")
|
b.Property<DateTime?>("DateImplement")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("Status")
|
b.Property<int>("Status")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
@ -104,6 +134,8 @@ namespace PlumbingRepairDataBaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ClientId");
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
|
|
||||||
b.HasIndex("WorkId");
|
b.HasIndex("WorkId");
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
@ -163,6 +195,10 @@ namespace PlumbingRepairDataBaseImplement.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("PlumbingRepairDataBaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
b.HasOne("PlumbingRepairDataBaseImplement.Models.Work", "Work")
|
b.HasOne("PlumbingRepairDataBaseImplement.Models.Work", "Work")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("WorkId")
|
.HasForeignKey("WorkId")
|
||||||
@ -171,6 +207,8 @@ namespace PlumbingRepairDataBaseImplement.Migrations
|
|||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
|
||||||
b.Navigation("Work");
|
b.Navigation("Work");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -203,6 +241,11 @@ namespace PlumbingRepairDataBaseImplement.Migrations
|
|||||||
b.Navigation("WorkComponents");
|
b.Navigation("WorkComponents");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Work", b =>
|
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Work", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Components");
|
b.Navigation("Components");
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using PlumbingRepairDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairDataBaseImplement.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<Order> Orders { get; set; } = new();
|
||||||
|
|
||||||
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Implementer()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
Password = model.Password,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
Qualification = model.Qualification
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
Password = model.Password;
|
||||||
|
WorkExperience = model.WorkExperience;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ImplementerFIO = ImplementerFIO,
|
||||||
|
Password = Password,
|
||||||
|
WorkExperience = WorkExperience,
|
||||||
|
Qualification = Qualification
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@ namespace PlumbingRepairDataBaseImplement.Models
|
|||||||
|
|
||||||
public int WorkId { get; private set; }
|
public int WorkId { get; private set; }
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
public int? ImplementerId { get; set; }
|
||||||
|
|
||||||
public string WorkName { get; private set; } = string.Empty;
|
public string WorkName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
@ -36,8 +37,9 @@ namespace PlumbingRepairDataBaseImplement.Models
|
|||||||
|
|
||||||
public virtual Work Work { get; set; }
|
public virtual Work Work { get; set; }
|
||||||
public virtual Client Client { get; set; }
|
public virtual Client Client { get; set; }
|
||||||
|
public virtual Implementer? Implementer { get; set; }
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -50,7 +52,8 @@ namespace PlumbingRepairDataBaseImplement.Models
|
|||||||
WorkId = model.WorkId,
|
WorkId = model.WorkId,
|
||||||
WorkName = model.WorkName,
|
WorkName = model.WorkName,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
Count = model.Count,
|
ImplementerId = model.ImplementerId,
|
||||||
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
@ -67,6 +70,7 @@ namespace PlumbingRepairDataBaseImplement.Models
|
|||||||
|
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
|
ImplementerId = model.ImplementerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
@ -76,6 +80,8 @@ namespace PlumbingRepairDataBaseImplement.Models
|
|||||||
WorkName = Work.WorkName,
|
WorkName = Work.WorkName,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
ClientFIO = Client.ClientFIO,
|
ClientFIO = Client.ClientFIO,
|
||||||
|
ImplementerId = ImplementerId,
|
||||||
|
ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
|
@ -24,5 +24,6 @@ namespace PlumbingRepairDataBaseImplement
|
|||||||
public virtual DbSet<WorkComponent> WorkComponents { set; get; }
|
public virtual DbSet<WorkComponent> WorkComponents { set; get; }
|
||||||
public virtual DbSet<Order> Orders { set; get; }
|
public virtual DbSet<Order> Orders { set; get; }
|
||||||
public virtual DbSet<Client> Clients { set; get; }
|
public virtual DbSet<Client> Clients { set; get; }
|
||||||
|
public virtual DbSet<Implementer> Implementers { set; get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IImplementerModel : IId
|
||||||
|
{
|
||||||
|
string ImplementerFIO { get; }
|
||||||
|
string Password { get; }
|
||||||
|
int WorkExperience { get; }
|
||||||
|
int Qualification { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,8 @@ namespace PlumbingRepairDataModels.Models
|
|||||||
int ClientId { get; }
|
int ClientId { get; }
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
double Sum { get; }
|
double Sum { get; }
|
||||||
|
int? ImplementerId { get; }
|
||||||
|
string WorkName { get; }
|
||||||
OrderStatus Status { get; }
|
OrderStatus Status { get; }
|
||||||
DateTime DateCreate { get; }
|
DateTime DateCreate { get; }
|
||||||
DateTime? DateImplement { get; }
|
DateTime? DateImplement { get; }
|
||||||
|
@ -15,10 +15,12 @@ namespace PlumbingRepairFileImplement
|
|||||||
private readonly string OrderFileName = "Order.xml";
|
private readonly string OrderFileName = "Order.xml";
|
||||||
private readonly string WorkFileName = "Work.xml";
|
private readonly string WorkFileName = "Work.xml";
|
||||||
private readonly string ClientFileName = "Client.xml";
|
private readonly string ClientFileName = "Client.xml";
|
||||||
|
private readonly string ImplementerFileName = "Implementer.xml";
|
||||||
public List<Component> Components { get; private set; }
|
public List<Component> Components { get; private set; }
|
||||||
public List<Order> Orders { get; private set; }
|
public List<Order> Orders { get; private set; }
|
||||||
public List<Work> Works { get; private set; }
|
public List<Work> Works { get; private set; }
|
||||||
public List<Client> Clients { get; private set; }
|
public List<Client> Clients { get; private set; }
|
||||||
|
public List<Implementer> Implementers { get; private set; }
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
{
|
{
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
@ -35,6 +37,8 @@ namespace PlumbingRepairFileImplement
|
|||||||
"Orders", x => x.GetXElement);
|
"Orders", x => x.GetXElement);
|
||||||
public void SaveClients() => SaveData(Clients, ClientFileName,
|
public void SaveClients() => SaveData(Clients, ClientFileName,
|
||||||
"Clients", x => x.GetXElement);
|
"Clients", x => x.GetXElement);
|
||||||
|
public void SaveImplementers() => SaveData(Implementers, ImplementerFileName,
|
||||||
|
"Implementers", x => x.GetXElement);
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
{
|
{
|
||||||
Components = LoadData(ComponentFileName, "Component", x =>
|
Components = LoadData(ComponentFileName, "Component", x =>
|
||||||
@ -43,6 +47,8 @@ namespace PlumbingRepairFileImplement
|
|||||||
Work.Create(x)!)!;
|
Work.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||||
|
Implementers = LoadData(ImplementerFileName, "Implementer", x =>
|
||||||
|
Implementer.Create(x)!)!;
|
||||||
}
|
}
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
||||||
Func<XElement, T> selectFunction)
|
Func<XElement, T> selectFunction)
|
||||||
|
@ -0,0 +1,88 @@
|
|||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.SearchModels;
|
||||||
|
using PlumbingRepairContracts.StoragesContracts;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using PlumbingRepairFileImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class ImplementerStorage : IImplementerStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton source;
|
||||||
|
public ImplementerStorage()
|
||||||
|
{
|
||||||
|
source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return source.Implementers
|
||||||
|
.FirstOrDefault(x => (x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(model.ImplementerFIO) && !string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
return source.Implementers
|
||||||
|
.FirstOrDefault(x => (x.ImplementerFIO == model.ImplementerFIO && x.Password == model.Password))?.GetViewModel;
|
||||||
|
}
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
return source.Implementers.Where(x =>
|
||||||
|
x.ImplementerFIO.Contains(model.ImplementerFIO)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return source.Implementers.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -27,11 +27,36 @@ namespace PlumbingRepairFileImplement.Implements
|
|||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue && !model.DateFrom.HasValue)
|
if (model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return source.Orders
|
||||||
|
.Where(x => x.Id == model.Id)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
return source.Orders.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
else if (model.DateFrom != null && model.DateTo != null)
|
||||||
|
{
|
||||||
|
return source.Orders
|
||||||
|
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.ClientId.HasValue)
|
||||||
|
{
|
||||||
|
return source.Orders
|
||||||
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.ImplementerId.HasValue)
|
||||||
|
{
|
||||||
|
return source.Orders
|
||||||
|
.Where(x => x.ImplementerId == model.ImplementerId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
|
@ -0,0 +1,81 @@
|
|||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using PlumbingRepairDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace PlumbingRepairFileImplement.Models
|
||||||
|
{
|
||||||
|
public class Implementer : IImplementerModel
|
||||||
|
{
|
||||||
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
|
public int Qualification { get; set; }
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public static Implementer? Create(ImplementerBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Implementer()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
Password = model.Password,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
Qualification = model.Qualification
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static Implementer? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Implementer()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
ImplementerFIO = element.Element("ImplementerFIO")!.Value,
|
||||||
|
Password = element.Element("Password")!.Value,
|
||||||
|
WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value),
|
||||||
|
Qualification = Convert.ToInt32(element.Element("Qualification")!.Value)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ImplementerBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
Password = model.Password;
|
||||||
|
WorkExperience = model.WorkExperience;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ImplementerFIO = ImplementerFIO,
|
||||||
|
Password = Password,
|
||||||
|
WorkExperience = WorkExperience,
|
||||||
|
Qualification = Qualification
|
||||||
|
};
|
||||||
|
public XElement GetXElement => new("Implementer",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("ImplementerFIO", ImplementerFIO),
|
||||||
|
new XElement("Password", Password),
|
||||||
|
new XElement("WorkExperience", WorkExperience),
|
||||||
|
new XElement("Qualification", Qualification));
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,7 @@ namespace PlumbingRepairFileImplement.Models
|
|||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public int WorkId { get; private set; }
|
public int WorkId { get; private set; }
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
public int? ImplementerId { get; private set; }
|
||||||
public String WorkName { get; private set; } = string.Empty;
|
public String WorkName { get; private set; } = string.Empty;
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
@ -35,7 +36,8 @@ namespace PlumbingRepairFileImplement.Models
|
|||||||
WorkId = model.WorkId,
|
WorkId = model.WorkId,
|
||||||
WorkName = model.WorkName,
|
WorkName = model.WorkName,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
Count = model.Count,
|
ImplementerId = model.ImplementerId,
|
||||||
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
@ -54,7 +56,8 @@ namespace PlumbingRepairFileImplement.Models
|
|||||||
WorkId = Convert.ToInt32(element.Element("WorkId")!.Value),
|
WorkId = Convert.ToInt32(element.Element("WorkId")!.Value),
|
||||||
WorkName = element.Element("WorkName")!.Value,
|
WorkName = element.Element("WorkName")!.Value,
|
||||||
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
|
||||||
|
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
||||||
@ -73,6 +76,7 @@ namespace PlumbingRepairFileImplement.Models
|
|||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateCreate = model.DateCreate;
|
DateCreate = model.DateCreate;
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
|
ImplementerId = model.ImplementerId;
|
||||||
}
|
}
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
@ -80,7 +84,8 @@ namespace PlumbingRepairFileImplement.Models
|
|||||||
WorkId = WorkId,
|
WorkId = WorkId,
|
||||||
WorkName = WorkName,
|
WorkName = WorkName,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
Count = Count,
|
ImplementerId = ImplementerId,
|
||||||
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
@ -91,7 +96,8 @@ namespace PlumbingRepairFileImplement.Models
|
|||||||
new XElement("WorkName", WorkName),
|
new XElement("WorkName", WorkName),
|
||||||
new XElement("WorkId", WorkId.ToString()),
|
new XElement("WorkId", WorkId.ToString()),
|
||||||
new XElement("ClientId", ClientId.ToString()),
|
new XElement("ClientId", ClientId.ToString()),
|
||||||
new XElement("Count", Count.ToString()),
|
new XElement("ImplementerId", ImplementerId),
|
||||||
|
new XElement("Count", Count.ToString()),
|
||||||
new XElement("Sum", Sum.ToString()),
|
new XElement("Sum", Sum.ToString()),
|
||||||
new XElement("Status", Status.ToString()),
|
new XElement("Status", Status.ToString()),
|
||||||
new XElement("DateCreate", DateCreate.ToString()),
|
new XElement("DateCreate", DateCreate.ToString()),
|
||||||
|
@ -14,12 +14,14 @@ namespace PlumbingRepairListImplement
|
|||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
public List<Work> Works { get; set; }
|
public List<Work> Works { get; set; }
|
||||||
public List<Client> Clients { get; set; }
|
public List<Client> Clients { get; set; }
|
||||||
|
public List<Implementer> Implementers { get; set; }
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
Components = new List<Component>();
|
Components = new List<Component>();
|
||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
Works = new List<Work>();
|
Works = new List<Work>();
|
||||||
Clients = new List<Client>();
|
Clients = new List<Client>();
|
||||||
|
Implementers = new List<Implementer>();
|
||||||
}
|
}
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,120 @@
|
|||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.SearchModels;
|
||||||
|
using PlumbingRepairContracts.StoragesContracts;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using PlumbingRepairListImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairListImplement.Implements
|
||||||
|
{
|
||||||
|
public class ImplementerStorage : IImplementerStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
public ImplementerStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
if (implementer.Id == model.Id)
|
||||||
|
{
|
||||||
|
return implementer.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(model.ImplementerFIO) && !string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
if (implementer.ImplementerFIO == model.ImplementerFIO && implementer.Password == model.Password)
|
||||||
|
{
|
||||||
|
return implementer.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||||
|
{
|
||||||
|
var result = new List<ImplementerViewModel>();
|
||||||
|
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 List<ImplementerViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var result = new List<ImplementerViewModel>();
|
||||||
|
foreach (var implementer in _source.Implementers)
|
||||||
|
{
|
||||||
|
result.Add(implementer.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -30,15 +30,41 @@ namespace PlumbingRepairListImplement.Implements
|
|||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
if (!model.Id.HasValue && !model.DateFrom.HasValue)
|
if (model.Id.HasValue)
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
if (model.DateFrom.HasValue)
|
|
||||||
{
|
{
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
if (model.Id.HasValue && order.Id == model.Id)
|
if (order.Id == model.Id)
|
||||||
|
{
|
||||||
|
result.Add(order.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (model.DateFrom != null && model.DateTo != null)
|
||||||
|
{
|
||||||
|
foreach (var order in _source.Orders)
|
||||||
|
{
|
||||||
|
if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
|
||||||
|
{
|
||||||
|
result.Add(order.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (model.ClientId.HasValue)
|
||||||
|
{
|
||||||
|
foreach (var order in _source.Orders)
|
||||||
|
{
|
||||||
|
if (order.ClientId == model.ClientId)
|
||||||
|
{
|
||||||
|
result.Add(order.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (model.ImplementerId.HasValue)
|
||||||
|
{
|
||||||
|
foreach (var order in _source.Orders)
|
||||||
|
{
|
||||||
|
if (order.ImplementerId == model.ImplementerId)
|
||||||
{
|
{
|
||||||
result.Add(order.GetViewModel);
|
result.Add(order.GetViewModel);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using PlumbingRepairDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairListImplement.Models
|
||||||
|
{
|
||||||
|
public class Implementer : IImplementerModel
|
||||||
|
{
|
||||||
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
|
public int Qualification { get; set; }
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
public static Implementer? Create(ImplementerBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Implementer()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
Password = model.Password,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
Qualification = model.Qualification
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ImplementerBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
Password = model.Password;
|
||||||
|
WorkExperience = model.WorkExperience;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ImplementerFIO = ImplementerFIO,
|
||||||
|
Password = Password,
|
||||||
|
WorkExperience = WorkExperience,
|
||||||
|
Qualification = Qualification
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ namespace PlumbingRepairListImplement.Models
|
|||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public int WorkId { get; private set; }
|
public int WorkId { get; private set; }
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
public int? ImplementerId { get; private set; }
|
||||||
public String WorkName { get; private set; } = string.Empty;
|
public String WorkName { get; private set; } = string.Empty;
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
@ -33,7 +34,8 @@ namespace PlumbingRepairListImplement.Models
|
|||||||
WorkId = model.WorkId,
|
WorkId = model.WorkId,
|
||||||
WorkName = model.WorkName,
|
WorkName = model.WorkName,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
Count = model.Count,
|
ImplementerId = model.ImplementerId,
|
||||||
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
@ -51,6 +53,7 @@ namespace PlumbingRepairListImplement.Models
|
|||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateCreate = model.DateCreate;
|
DateCreate = model.DateCreate;
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
|
ImplementerId = model.ImplementerId;
|
||||||
}
|
}
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
@ -58,7 +61,8 @@ namespace PlumbingRepairListImplement.Models
|
|||||||
WorkId = WorkId,
|
WorkId = WorkId,
|
||||||
WorkName = WorkName,
|
WorkName = WorkName,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
Count = Count,
|
ImplementerId = ImplementerId,
|
||||||
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
|
@ -0,0 +1,99 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||||
|
using PlumbingRepairContracts.SearchModels;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using PlumbingRepairDataModels.Enums;
|
||||||
|
|
||||||
|
namespace PlumbingRepairRestApi.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<ImplementerController> 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<OrderViewModel>? 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,8 +13,10 @@ builder.Logging.AddLog4Net("log4net.config");
|
|||||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
builder.Services.AddTransient<IWorkStorage, WorkStorage>();
|
builder.Services.AddTransient<IWorkStorage, WorkStorage>();
|
||||||
|
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
|
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
builder.Services.AddTransient<IWorkLogic, WorkLogic>();
|
builder.Services.AddTransient<IWorkLogic, WorkLogic>();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user