Готовая 5
This commit is contained in:
parent
3b1b9f88b4
commit
2fa3cbcfb4
@ -29,10 +29,6 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
Id = new DataGridViewTextBoxColumn();
|
||||
СlientFIO = new DataGridViewTextBoxColumn();
|
||||
Email = new DataGridViewTextBoxColumn();
|
||||
Password = new DataGridViewTextBoxColumn();
|
||||
buttonDelete = new Button();
|
||||
buttonUpdate = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
@ -42,7 +38,6 @@
|
||||
//
|
||||
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { Id, СlientFIO, Email, Password });
|
||||
dataGridView.Location = new Point(-4, 1);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
@ -50,34 +45,6 @@
|
||||
dataGridView.Size = new Size(657, 450);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// Id
|
||||
//
|
||||
Id.HeaderText = "Id";
|
||||
Id.MinimumWidth = 6;
|
||||
Id.Name = "Id";
|
||||
Id.Width = 125;
|
||||
//
|
||||
// СlientFIO
|
||||
//
|
||||
СlientFIO.HeaderText = "ФИО клиента";
|
||||
СlientFIO.MinimumWidth = 6;
|
||||
СlientFIO.Name = "СlientFIO";
|
||||
СlientFIO.Width = 125;
|
||||
//
|
||||
// Email
|
||||
//
|
||||
Email.HeaderText = "E-mail";
|
||||
Email.MinimumWidth = 6;
|
||||
Email.Name = "Email";
|
||||
Email.Width = 125;
|
||||
//
|
||||
// Password
|
||||
//
|
||||
Password.HeaderText = "Пароль";
|
||||
Password.MinimumWidth = 6;
|
||||
Password.Name = "Password";
|
||||
Password.Width = 125;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(671, 28);
|
||||
@ -117,9 +84,5 @@
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
private DataGridViewTextBoxColumn Id;
|
||||
private DataGridViewTextBoxColumn СlientFIO;
|
||||
private DataGridViewTextBoxColumn Email;
|
||||
private DataGridViewTextBoxColumn Password;
|
||||
}
|
||||
}
|
@ -57,16 +57,4 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="СlientFIO.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Email.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Password.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,158 +1,179 @@
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
partial class FormCreateOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
partial class FormCreateOrder
|
||||
{
|
||||
/// <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);
|
||||
}
|
||||
/// <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
|
||||
#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.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.comboBoxManufacture = new System.Windows.Forms.ComboBox();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.labelSum = new System.Windows.Forms.Label();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.textBoxSum = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(43, 41);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(68, 20);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Изделие";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(43, 97);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(90, 20);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "Количество";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(43, 151);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(58, 20);
|
||||
this.label3.TabIndex = 2;
|
||||
this.label3.Text = "Сумма:";
|
||||
//
|
||||
// comboBoxManufacture
|
||||
//
|
||||
this.comboBoxManufacture.FormattingEnabled = true;
|
||||
this.comboBoxManufacture.Location = new System.Drawing.Point(133, 38);
|
||||
this.comboBoxManufacture.Name = "comboBoxManufacture";
|
||||
this.comboBoxManufacture.Size = new System.Drawing.Size(446, 28);
|
||||
this.comboBoxManufacture.TabIndex = 3;
|
||||
this.comboBoxManufacture.SelectedIndexChanged += new System.EventHandler(this.ComboBoxManufacture_SelectedIndexChanged);
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(133, 94);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(446, 27);
|
||||
this.textBoxCount.TabIndex = 4;
|
||||
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
||||
//
|
||||
// labelSum
|
||||
//
|
||||
this.labelSum.AutoSize = true;
|
||||
this.labelSum.BackColor = System.Drawing.SystemColors.ActiveBorder;
|
||||
this.labelSum.Location = new System.Drawing.Point(133, 151);
|
||||
this.labelSum.Name = "labelSum";
|
||||
this.labelSum.Size = new System.Drawing.Size(0, 20);
|
||||
this.labelSum.TabIndex = 5;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(332, 216);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonSave.TabIndex = 6;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(485, 216);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonCancel.TabIndex = 7;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// textBoxSum
|
||||
//
|
||||
this.textBoxSum.BackColor = System.Drawing.SystemColors.ActiveBorder;
|
||||
this.textBoxSum.Location = new System.Drawing.Point(133, 151);
|
||||
this.textBoxSum.Name = "textBoxSum";
|
||||
this.textBoxSum.ReadOnly = true;
|
||||
this.textBoxSum.Size = new System.Drawing.Size(446, 27);
|
||||
this.textBoxSum.TabIndex = 8;
|
||||
|
||||
//
|
||||
// FormCreateOrder
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(720, 257);
|
||||
this.Controls.Add(this.textBoxSum);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.labelSum);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.comboBoxManufacture);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Name = "FormCreateOrder";
|
||||
this.Text = "Создание заказа";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
comboBoxManufacture = new ComboBox();
|
||||
textBoxCount = new TextBox();
|
||||
labelSum = new Label();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
textBoxSum = new TextBox();
|
||||
label4 = new Label();
|
||||
comboBoxClients = new ComboBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(44, 18);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(68, 20);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Изделие";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(22, 68);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(90, 20);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Количество";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(54, 154);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(58, 20);
|
||||
label3.TabIndex = 2;
|
||||
label3.Text = "Сумма:";
|
||||
//
|
||||
// comboBoxManufacture
|
||||
//
|
||||
comboBoxManufacture.FormattingEnabled = true;
|
||||
comboBoxManufacture.Location = new Point(133, 10);
|
||||
comboBoxManufacture.Name = "comboBoxManufacture";
|
||||
comboBoxManufacture.Size = new Size(446, 28);
|
||||
comboBoxManufacture.TabIndex = 3;
|
||||
comboBoxManufacture.SelectedIndexChanged += ComboBoxManufacture_SelectedIndexChanged;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(133, 65);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(446, 27);
|
||||
textBoxCount.TabIndex = 4;
|
||||
textBoxCount.TextChanged += TextBoxCount_TextChanged;
|
||||
//
|
||||
// labelSum
|
||||
//
|
||||
labelSum.AutoSize = true;
|
||||
labelSum.BackColor = SystemColors.ActiveBorder;
|
||||
labelSum.Location = new Point(133, 151);
|
||||
labelSum.Name = "labelSum";
|
||||
labelSum.Size = new Size(0, 20);
|
||||
labelSum.TabIndex = 5;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(332, 216);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(485, 216);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// textBoxSum
|
||||
//
|
||||
textBoxSum.BackColor = SystemColors.ActiveBorder;
|
||||
textBoxSum.Location = new Point(133, 151);
|
||||
textBoxSum.Name = "textBoxSum";
|
||||
textBoxSum.ReadOnly = true;
|
||||
textBoxSum.Size = new Size(446, 27);
|
||||
textBoxSum.TabIndex = 8;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(62, 110);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(58, 20);
|
||||
label4.TabIndex = 9;
|
||||
label4.Text = "Клиент";
|
||||
//
|
||||
// comboBoxClients
|
||||
//
|
||||
comboBoxClients.FormattingEnabled = true;
|
||||
comboBoxClients.Location = new Point(133, 107);
|
||||
comboBoxClients.Name = "comboBoxClients";
|
||||
comboBoxClients.Size = new Size(446, 28);
|
||||
comboBoxClients.TabIndex = 10;
|
||||
//
|
||||
// FormCreateOrder
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(720, 257);
|
||||
Controls.Add(comboBoxClients);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(textBoxSum);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(labelSum);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(comboBoxManufacture);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Name = "FormCreateOrder";
|
||||
Text = "Создание заказа";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private ComboBox comboBoxManufacture;
|
||||
private TextBox textBoxCount;
|
||||
private Label labelSum;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private TextBox textBoxSum;
|
||||
}
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private ComboBox comboBoxManufacture;
|
||||
private TextBox textBoxCount;
|
||||
private Label labelSum;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private TextBox textBoxSum;
|
||||
private Label label4;
|
||||
private ComboBox comboBoxClients;
|
||||
}
|
||||
}
|
@ -15,127 +15,143 @@ using System.Windows.Forms;
|
||||
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
public partial class FormCreateOrder : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IManufactureLogic _logicM;
|
||||
private readonly IOrderLogic _logicO;
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IManufactureLogic logicM, IOrderLogic logicO)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logicM = logicM;
|
||||
_logicO = logicO;
|
||||
LoadData();
|
||||
}
|
||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделий для заказа");
|
||||
LoadData();
|
||||
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
var _list = _logicM.ReadList(null);
|
||||
|
||||
if (_list != null)
|
||||
{
|
||||
comboBoxManufacture.DisplayMember = "ManufactureName";
|
||||
comboBoxManufacture.ValueMember = "Id";
|
||||
comboBoxManufacture.DataSource = _list;
|
||||
comboBoxManufacture.SelectedItem = null;
|
||||
}
|
||||
|
||||
}
|
||||
private void CalcSum()
|
||||
{
|
||||
if (comboBoxManufacture.SelectedValue != null &&
|
||||
!string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(comboBoxManufacture.SelectedValue);
|
||||
var product = _logicM.ReadElement(new ManufactureSearchModel
|
||||
{
|
||||
Id
|
||||
= id
|
||||
});
|
||||
int count = Convert.ToInt32(textBoxCount.Text);
|
||||
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0),
|
||||
2).ToString();
|
||||
_logger.LogInformation("Расчет суммы заказа");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void TextBoxCount_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
public partial class FormCreateOrder : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IManufactureLogic _logicM;
|
||||
private readonly IOrderLogic _logicO;
|
||||
private readonly IClientLogic _logicC;
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IManufactureLogic logicM, IOrderLogic logicO, IClientLogic logicC)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
private void ComboBoxManufacture_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
_logger = logger;
|
||||
_logicM = logicM;
|
||||
_logicO = logicO;
|
||||
_logicC = logicC;
|
||||
LoadData();
|
||||
}
|
||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделий для заказа");
|
||||
LoadData();
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxManufacture.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Создание заказа");
|
||||
try
|
||||
{
|
||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||
{
|
||||
ManufactureId = Convert.ToInt32(comboBoxManufacture.SelectedValue),
|
||||
ManufactureName = comboBoxManufacture.Text,
|
||||
Count = Convert.ToInt32(textBoxCount.Text),
|
||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||
});
|
||||
|
||||
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 LoadData()
|
||||
{
|
||||
var _list = _logicM.ReadList(null);
|
||||
var _listClient = _logicC.ReadList(null);
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
if (_list != null && _listClient != null)
|
||||
{
|
||||
comboBoxManufacture.DisplayMember = "ManufactureName";
|
||||
comboBoxManufacture.ValueMember = "Id";
|
||||
comboBoxManufacture.DataSource = _list;
|
||||
comboBoxManufacture.SelectedItem = null;
|
||||
|
||||
comboBoxClients.DisplayMember = "ClientFIO";
|
||||
comboBoxClients.ValueMember = "Id";
|
||||
comboBoxClients.DataSource = _listClient;
|
||||
comboBoxClients.SelectedItem = null;
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
var _list = _logicM.ReadList(null);
|
||||
MessageBox.Show(_list.Count.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CalcSum()
|
||||
{
|
||||
if (comboBoxManufacture.SelectedValue != null &&
|
||||
!string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(comboBoxManufacture.SelectedValue);
|
||||
var product = _logicM.ReadElement(new ManufactureSearchModel
|
||||
{
|
||||
Id
|
||||
= id
|
||||
});
|
||||
int count = Convert.ToInt32(textBoxCount.Text);
|
||||
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0),
|
||||
2).ToString();
|
||||
_logger.LogInformation("Расчет суммы заказа");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void TextBoxCount_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
|
||||
}
|
||||
private void ComboBoxManufacture_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxManufacture.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxClients.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите клиента", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Создание заказа");
|
||||
try
|
||||
{
|
||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||
{
|
||||
ManufactureId = Convert.ToInt32(comboBoxManufacture.SelectedValue),
|
||||
ManufactureName = comboBoxManufacture.Text,
|
||||
Count = Convert.ToInt32(textBoxCount.Text),
|
||||
Sum = Convert.ToDouble(textBoxSum.Text),
|
||||
ClientId = Convert.ToInt32(comboBoxClients.SelectedValue)
|
||||
|
||||
});
|
||||
|
||||
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 button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
var _list = _logicM.ReadList(null);
|
||||
MessageBox.Show(_list.Count.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,9 @@ namespace BlacksmithWorkshop
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
LoadData();
|
||||
|
||||
_reportLogic = reportLogic;
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
@ -44,6 +45,7 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ManufactureId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
|
||||
}
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
@ -104,7 +106,9 @@ namespace BlacksmithWorkshop
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString())
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
ClientId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value)
|
||||
|
||||
|
||||
|
||||
});
|
||||
@ -143,7 +147,8 @@ namespace BlacksmithWorkshop
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString())
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
ClientId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value)
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
@ -180,7 +185,9 @@ namespace BlacksmithWorkshop
|
||||
ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString())
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
ClientId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value)
|
||||
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
|
@ -24,6 +24,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
|
||||
}
|
||||
public bool Create(ClientBindingModel model)
|
||||
{
|
||||
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Insert(model) == null)
|
||||
{
|
||||
@ -65,7 +66,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
|
||||
|
||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadElement. ClientFIO:{ ClientFIO}. ClientEmail:{ ClientEmail}. Id:{ Id}", model.ClientFIO, model.Email, model.Id);
|
||||
_logger.LogInformation("ReadElement. ClientFIO:{ ClientFIO}. ClientEmail:{ ClientEmail}. Id:{ Id}", model?.ClientFIO, model?.Email, model?.Id);
|
||||
var list = model == null ? _clientStorage.GetFullList() :
|
||||
_clientStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
|
@ -57,9 +57,6 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
|
||||
record.Components.Add(new Tuple<string,
|
||||
int>(component.Value.Item1.ComponentName, component.Value.Item2));
|
||||
record.TotalCount += component.Value.Item2;
|
||||
|
||||
|
||||
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
|
@ -24,19 +24,6 @@ WordTextProperties { Bold = true, Size = "24", }) },
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
/* foreach (var component in info.Components)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> {
|
||||
(component.ComponentName, new WordTextProperties { Size = "24"}) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
}*/
|
||||
foreach (var manufacture in info.Manufactures)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
|
@ -1,7 +1,9 @@
|
||||
using BlacksmithWorkshopClientApp.Models;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace BlacksmithWorkshopClientApp.Controllers
|
||||
@ -128,6 +130,8 @@ namespace BlacksmithWorkshopClientApp.Controllers
|
||||
{
|
||||
throw new Exception("Количество и сумма должны быть больше 0");
|
||||
}
|
||||
|
||||
|
||||
APIClient.PostRequest("api/main/createorder", new
|
||||
OrderBindingModel
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
using BlacksmithWorkshopClientApp;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
APIClient.Connect(builder.Configuration);
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание заказа</h2>
|
||||
</div>
|
||||
@ -8,7 +9,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Изделие:</div>
|
||||
<div class="col-8">
|
||||
<select id="manufacture" name="manufacture" class="form-control" aspitems="@(new SelectList(@ViewBag.Products,"Id", "ProductName"))"></select>
|
||||
<select id="manufacture" name="manufacture" class="form-control" asp-items="@(new SelectList(@ViewBag.Manufactures,"Id", "ManufactureName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -32,13 +33,15 @@ btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$('#product').on('change', function () {
|
||||
|
||||
$('#manufacture').on('change', function () {
|
||||
check();
|
||||
});
|
||||
$('#count').on('change', function () {
|
||||
check();
|
||||
});
|
||||
function check() {
|
||||
|
||||
var count = $('#count').val();
|
||||
var manufacture = $('#manufacture').val();
|
||||
if (count && manufacture) {
|
||||
|
@ -1,27 +1,75 @@
|
||||
@{
|
||||
ViewData["Title"] = "Register";
|
||||
@using BlacksmithWorkshopContracts.ViewModels
|
||||
@model List<OrderViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
<h1 class="display-4">Заказы</h1>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8"><input type="text" name="login" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8"><input type="password" name="password" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО:</div>
|
||||
<div class="col-8"><input type="text" name="fio" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Регистрация"
|
||||
class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="Create">Создать заказ</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Изделие
|
||||
</th>
|
||||
<th>
|
||||
Дата создания
|
||||
</th>
|
||||
<th>
|
||||
Количество
|
||||
</th>
|
||||
<th>
|
||||
Сумма
|
||||
</th>
|
||||
<th>
|
||||
Статус
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.ManufactureName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.DateCreate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.Count)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.Status)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -1,6 +1,38 @@
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
@using BlacksmithWorkshopContracts.ViewModels
|
||||
@model ClientViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Личные данные</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="login"
|
||||
value="@Model.Email" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8">
|
||||
<input type="password" name="password"
|
||||
value="@Model.Password" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="fio"
|
||||
value="@Model.ClientFIO" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Сохранить" class="btn
|
||||
btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
@ -1,38 +1,28 @@
|
||||
@using BlacksmithWorkshopContracts.ViewModels
|
||||
@model ClientViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
@{
|
||||
ViewData["Title"] = "Register";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Личные данные</h2>
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="login"
|
||||
value="@Model.Email" />
|
||||
</div>
|
||||
<div class="col-8"><input type="text" name="login" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8">
|
||||
<input type="password" name="password"
|
||||
value="@Model.Password" />
|
||||
</div>
|
||||
<div class="col-8"><input type="password" name="password" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="fio"
|
||||
value="@Model.ClientFIO" />
|
||||
</div>
|
||||
<div class="col-8"><input type="text" name="fio" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Сохранить" class="btn
|
||||
btn-primary" />
|
||||
<input type="submit" value="Регистрация"
|
||||
class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
@ -7,12 +7,13 @@
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/BlacksmithWorkshopClientApp.styles.css" asp-append-version="true" />
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bgwhite border-bottom box-shadow mb-3">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Абстрактный магазин</a>
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Мастерская кузнечных изделий</a>
|
||||
<button class="navbar-toggler" type="button" datatoggle="collapse" data-target=".navbar-collapse" ariacontrols="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
@ -43,7 +44,7 @@
|
||||
</div>
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2020 - Абстрактный магазин - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Личные данные</a>
|
||||
© 2020 - Мастерская кузнечных изделий - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
|
@ -36,5 +36,6 @@ namespace BlacksmithWorkshopContracts.BusinessLogicsContracts
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,5 @@ namespace BlacksmithWorkshopDataModel.Models
|
||||
{
|
||||
string ComponentName { get; }
|
||||
double Cost { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ClientFIO) && string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -79,7 +79,16 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
|
||||
public ClientViewModel? Update(ClientBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
var client = context.Clients.FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
client.Update(model);
|
||||
context.SaveChanges();
|
||||
return client.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
var element = context.Orders
|
||||
var element = context.Orders.Include(x => x.Manufacture)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
@ -35,7 +35,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
return context.Orders
|
||||
return context.Orders.Include(x => x.Manufacture)
|
||||
.FirstOrDefault(x =>
|
||||
(model.Id.HasValue && x.Id ==
|
||||
model.Id))
|
||||
@ -44,22 +44,35 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
return context.Orders
|
||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || model.ClientId == x.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
/* return context.Orders
|
||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || model.ClientId == x.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();*/
|
||||
if (model.ClientId.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Client).Include(x => x.Manufacture)
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return context.Orders
|
||||
.Include(x => x.ManufactureName).Include(x => x.Manufacture)
|
||||
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
return context.Orders
|
||||
.ToList()
|
||||
return context.Orders.Include(x => x.Manufacture)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -74,14 +87,14 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
}
|
||||
context.Orders.Add(newProduct);
|
||||
context.SaveChanges();
|
||||
return newProduct.GetViewModel;
|
||||
}
|
||||
return context.Orders.Include(x => x.Manufacture).Include(x => x.Client).FirstOrDefault(x => x.Id == newProduct.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
|
||||
var product = context.Orders.FirstOrDefault(rec =>
|
||||
var product = context.Orders.Include(x => x.Manufacture).FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
if (product == null)
|
||||
{
|
||||
@ -97,7 +110,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
{
|
||||
OrderViewModel orderViewModel = order.GetViewModel;
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
var product = context.Orders.FirstOrDefault(rec =>
|
||||
var product = context.Orders.Include(x => x.Manufacture).FirstOrDefault(rec =>
|
||||
rec.Id == order.Id);
|
||||
if(product != null) { orderViewModel.ManufactureName = product.ManufactureName; }
|
||||
return orderViewModel;
|
||||
|
@ -9,120 +9,64 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
public partial class InitMigration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
//migrationBuilder.Sql("DELETE FROM [dbo].[Orders]");
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Components",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Cost = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Components", x => x.Id);
|
||||
});
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql("DELETE FROM [dbo].[Orders]");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Manufactures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ManufactureName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Manufactures", x => x.Id);
|
||||
});
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ClientId",
|
||||
table: "Orders",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ManufactureComponents",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ManufactureId = table.Column<int>(type: "int", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
ProductId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ManufactureComponents", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ManufactureComponents_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ManufactureComponents_Manufactures_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Manufactures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ManufactureId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false),
|
||||
ManufactureName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
ProductId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Manufactures_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Manufactures",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ManufactureComponents_ComponentId",
|
||||
table: "ManufactureComponents",
|
||||
column: "ComponentId");
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId",
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ManufactureComponents_ProductId",
|
||||
table: "ManufactureComponents",
|
||||
column: "ProductId");
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ProductId",
|
||||
table: "Orders",
|
||||
column: "ProductId");
|
||||
}
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ManufactureComponents");
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Manufactures");
|
||||
}
|
||||
}
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ClientId",
|
||||
table: "Orders");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
201
BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230327051139_Lab5Migra.Designer.cs
generated
Normal file
201
BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230327051139_Lab5Migra.Designer.cs
generated
Normal file
@ -0,0 +1,201 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BlacksmithWorkshopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BlacksmithWorkshopDatabase))]
|
||||
[Migration("20230327051139_Lab5Migra")]
|
||||
partial class Lab5Migra
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ManufactureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Manufactures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.ToTable("ManufactureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ManufactureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ManufactureComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", null)
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("ManufactureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Lab5Migra : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ClientId",
|
||||
table: "Orders",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ClientId",
|
||||
table: "Orders");
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,31 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -96,6 +121,9 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
|
@ -27,10 +27,12 @@ namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
public virtual Client Client { get; set; }
|
||||
public virtual Manufacture Manufacture { get; set; }
|
||||
|
||||
|
||||
|
||||
public static Order? Create(OrderBindingModel model)
|
||||
{
|
||||
@ -48,7 +50,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
ClientId = model.ClientId
|
||||
ClientId = model.ClientId,
|
||||
|
||||
|
||||
|
||||
};
|
||||
@ -73,19 +76,26 @@ namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
|
||||
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
public OrderViewModel GetViewModel
|
||||
{
|
||||
Id = Id,
|
||||
ManufactureId = ManufactureId,
|
||||
ManufactureName = ManufactureName,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
ClientId = ClientId
|
||||
};
|
||||
|
||||
get
|
||||
{
|
||||
var context = new BlacksmithWorkshopDatabase();
|
||||
return new()
|
||||
{
|
||||
Id = Id,
|
||||
ManufactureId = ManufactureId,
|
||||
ManufactureName = Manufacture.ManufactureName,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
ClientId = ClientId,
|
||||
ClientFIO = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ namespace BlacksmithWorkshopFileImplement.Implements
|
||||
client.Update(model);
|
||||
source.SaveComponents();
|
||||
return client.GetViewModel;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ namespace BlacksmithWorkshopListImplement.Implements
|
||||
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.Id == model.Id && model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo || order.ClientId == model.ClientId)
|
||||
if (order.Id == model.Id || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo || order.ClientId == model.ClientId)
|
||||
{
|
||||
result.Add(order.GetViewModel);
|
||||
}
|
||||
@ -119,7 +119,16 @@ namespace BlacksmithWorkshopListImplement.Implements
|
||||
orderViewModel.ManufactureName = manufacture.ManufactureName;
|
||||
}
|
||||
}
|
||||
return orderViewModel;
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if (client.Id == order.ClientId)
|
||||
{
|
||||
orderViewModel.ClientFIO = client.ClientFIO;
|
||||
}
|
||||
}
|
||||
return orderViewModel;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,9 @@ namespace BlacksmithWorkshopListImplement.Models
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public int ClientId { get; set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -80,6 +81,6 @@ namespace BlacksmithWorkshopListImplement.Models
|
||||
ClientId = ClientId
|
||||
};
|
||||
|
||||
public int ClientId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,12 +25,13 @@ namespace BlacksmithWorkshopRestApi.Controllers
|
||||
public List<ManufactureViewModel>? GetManufactureList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _manufacture.ReadList(null);
|
||||
}
|
||||
|
||||
{
|
||||
return _manufacture.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка продуктов");
|
||||
_logger.LogError(ex, "Ошибка получения списка изделий");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@ -57,7 +58,8 @@ namespace BlacksmithWorkshopRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
return _order.ReadList(new OrderSearchModel
|
||||
|
||||
return _order.ReadList(new OrderSearchModel
|
||||
{
|
||||
ClientId = clientId
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user