Изменение названий
This commit is contained in:
parent
20dd765c91
commit
a71ea5188a
22
FoodOrders/FoodOrders/FormCreateOrder.Designer.cs
generated
22
FoodOrders/FoodOrders/FormCreateOrder.Designer.cs
generated
@ -32,7 +32,7 @@
|
|||||||
this.buttonSave = new System.Windows.Forms.Button();
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
this.textBoxSum = new System.Windows.Forms.TextBox();
|
this.textBoxSum = new System.Windows.Forms.TextBox();
|
||||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
this.comboBoxSetOfDishes = new System.Windows.Forms.ComboBox();
|
this.comboBoxDish = new System.Windows.Forms.ComboBox();
|
||||||
this.labelSum = new System.Windows.Forms.Label();
|
this.labelSum = new System.Windows.Forms.Label();
|
||||||
this.labelCount = new System.Windows.Forms.Label();
|
this.labelCount = new System.Windows.Forms.Label();
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
this.labelName = new System.Windows.Forms.Label();
|
||||||
@ -77,15 +77,15 @@
|
|||||||
this.textBoxCount.TabIndex = 12;
|
this.textBoxCount.TabIndex = 12;
|
||||||
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
||||||
//
|
//
|
||||||
// comboBoxSetOfDishes
|
// comboBoxDish
|
||||||
//
|
//
|
||||||
this.comboBoxSetOfDishes.FormattingEnabled = true;
|
this.comboBoxDish.FormattingEnabled = true;
|
||||||
this.comboBoxSetOfDishes.Location = new System.Drawing.Point(93, 9);
|
this.comboBoxDish.Location = new System.Drawing.Point(93, 9);
|
||||||
this.comboBoxSetOfDishes.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
this.comboBoxDish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
this.comboBoxSetOfDishes.Name = "comboBoxSetOfDishes";
|
this.comboBoxDish.Name = "comboBoxDish";
|
||||||
this.comboBoxSetOfDishes.Size = new System.Drawing.Size(230, 23);
|
this.comboBoxDish.Size = new System.Drawing.Size(230, 23);
|
||||||
this.comboBoxSetOfDishes.TabIndex = 11;
|
this.comboBoxDish.TabIndex = 11;
|
||||||
this.comboBoxSetOfDishes.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSetOfDishes_SelectedIndexChanged);
|
this.comboBoxDish.SelectedIndexChanged += new System.EventHandler(this.ComboBoxDish_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// labelSum
|
// labelSum
|
||||||
//
|
//
|
||||||
@ -123,7 +123,7 @@
|
|||||||
this.Controls.Add(this.buttonSave);
|
this.Controls.Add(this.buttonSave);
|
||||||
this.Controls.Add(this.textBoxSum);
|
this.Controls.Add(this.textBoxSum);
|
||||||
this.Controls.Add(this.textBoxCount);
|
this.Controls.Add(this.textBoxCount);
|
||||||
this.Controls.Add(this.comboBoxSetOfDishes);
|
this.Controls.Add(this.comboBoxDish);
|
||||||
this.Controls.Add(this.labelSum);
|
this.Controls.Add(this.labelSum);
|
||||||
this.Controls.Add(this.labelCount);
|
this.Controls.Add(this.labelCount);
|
||||||
this.Controls.Add(this.labelName);
|
this.Controls.Add(this.labelName);
|
||||||
@ -141,7 +141,7 @@
|
|||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private TextBox textBoxSum;
|
private TextBox textBoxSum;
|
||||||
private TextBox textBoxCount;
|
private TextBox textBoxCount;
|
||||||
private ComboBox comboBoxSetOfDishes;
|
private ComboBox comboBoxDish;
|
||||||
private Label labelSum;
|
private Label labelSum;
|
||||||
private Label labelCount;
|
private Label labelCount;
|
||||||
private Label labelName;
|
private Label labelName;
|
||||||
|
@ -8,9 +8,9 @@ namespace FoodOrdersView
|
|||||||
public partial class FormCreateOrder : Form
|
public partial class FormCreateOrder : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ISetOfDishesLogic _logicS;
|
private readonly IDishLogic _logicS;
|
||||||
private readonly IOrderLogic _logicO;
|
private readonly IOrderLogic _logicO;
|
||||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISetOfDishesLogic logicS, IOrderLogic logicO)
|
public FormCreateOrder(ILogger<FormCreateOrder> logger, IDishLogic logicS, IOrderLogic logicO)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
@ -25,10 +25,10 @@ namespace FoodOrdersView
|
|||||||
var list = _logicS.ReadList(null);
|
var list = _logicS.ReadList(null);
|
||||||
if (list != null)
|
if (list != null)
|
||||||
{
|
{
|
||||||
comboBoxSetOfDishes.DisplayMember = "SetOfDishesName";
|
comboBoxDish.DisplayMember = "DishName";
|
||||||
comboBoxSetOfDishes.ValueMember = "Id";
|
comboBoxDish.ValueMember = "Id";
|
||||||
comboBoxSetOfDishes.DataSource = list;
|
comboBoxDish.DataSource = list;
|
||||||
comboBoxSetOfDishes.SelectedItem = null;
|
comboBoxDish.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -40,12 +40,12 @@ namespace FoodOrdersView
|
|||||||
}
|
}
|
||||||
private void CalcSum()
|
private void CalcSum()
|
||||||
{
|
{
|
||||||
if (comboBoxSetOfDishes.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
|
if (comboBoxDish.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(comboBoxSetOfDishes.SelectedValue);
|
int id = Convert.ToInt32(comboBoxDish.SelectedValue);
|
||||||
var product = _logicS.ReadElement(new SetOfDishesearchModel
|
var product = _logicS.ReadElement(new DishSearchModel
|
||||||
{
|
{
|
||||||
Id = id
|
Id = id
|
||||||
});
|
});
|
||||||
@ -65,7 +65,7 @@ namespace FoodOrdersView
|
|||||||
{
|
{
|
||||||
CalcSum();
|
CalcSum();
|
||||||
}
|
}
|
||||||
private void ComboBoxSetOfDishes_SelectedIndexChanged(object sender, EventArgs e)
|
private void ComboBoxDish_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CalcSum();
|
CalcSum();
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ namespace FoodOrdersView
|
|||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (comboBoxSetOfDishes.SelectedValue == null)
|
if (comboBoxDish.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите Набор блюд", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Выберите Набор блюд", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
@ -87,8 +87,8 @@ namespace FoodOrdersView
|
|||||||
{
|
{
|
||||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
SetOfDishesId = Convert.ToInt32(comboBoxSetOfDishes.SelectedValue),
|
DishId = Convert.ToInt32(comboBoxDish.SelectedValue),
|
||||||
SetOfDishesName = comboBoxSetOfDishes.Text,
|
DishName = comboBoxDish.Text,
|
||||||
Count = Convert.ToInt32(textBoxCount.Text),
|
Count = Convert.ToInt32(textBoxCount.Text),
|
||||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||||
});
|
});
|
||||||
|
14
FoodOrders/FoodOrders/FormDish.Designer.cs
generated
14
FoodOrders/FoodOrders/FormDish.Designer.cs
generated
@ -1,11 +1,11 @@
|
|||||||
namespace FoodOrdersView
|
namespace FoodOrdersView
|
||||||
{
|
{
|
||||||
partial class FormDish
|
partial class FormComponent
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer Dishes = null;
|
private System.ComponentModel.IContainer Components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
@ -13,9 +13,9 @@
|
|||||||
/// <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 && (Dishes != null))
|
if (disposing && (Components != null))
|
||||||
{
|
{
|
||||||
Dishes.Dispose();
|
Components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@
|
|||||||
this.labelBlankName.TabIndex = 6;
|
this.labelBlankName.TabIndex = 6;
|
||||||
this.labelBlankName.Text = "Название:";
|
this.labelBlankName.Text = "Название:";
|
||||||
//
|
//
|
||||||
// FormDish
|
// FormComponent
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
@ -103,9 +103,9 @@
|
|||||||
this.Controls.Add(this.textBoxName);
|
this.Controls.Add(this.textBoxName);
|
||||||
this.Controls.Add(this.labelPrice);
|
this.Controls.Add(this.labelPrice);
|
||||||
this.Controls.Add(this.labelBlankName);
|
this.Controls.Add(this.labelBlankName);
|
||||||
this.Name = "FormDish";
|
this.Name = "FormComponent";
|
||||||
this.Text = "Блюдо";
|
this.Text = "Блюдо";
|
||||||
this.Load += new System.EventHandler(this.FormDish_Load);
|
this.Load += new System.EventHandler(this.FormComponent_Load);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
@ -5,34 +5,34 @@ using FoodOrdersContracts.BindingModels;
|
|||||||
|
|
||||||
namespace FoodOrdersView
|
namespace FoodOrdersView
|
||||||
{
|
{
|
||||||
public partial class FormDish : Form
|
public partial class FormComponent : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IDishLogic _logic;
|
private readonly IComponentLogic _logic;
|
||||||
private int? _id;
|
private int? _id;
|
||||||
public int Id { set { _id = value; } }
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
public FormDish(ILogger<FormDish> logger, IDishLogic logic)
|
public FormComponent(ILogger<FormComponent> logger, IComponentLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormDish_Load(object sender, EventArgs e)
|
private void FormComponent_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_id.HasValue)
|
if (_id.HasValue)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Получение блюда");
|
_logger.LogInformation("Получение блюда");
|
||||||
var view = _logic.ReadElement(new DishesearchModel
|
var view = _logic.ReadElement(new ComponentSearchModel
|
||||||
{
|
{
|
||||||
Id = _id.Value
|
Id = _id.Value
|
||||||
});
|
});
|
||||||
if (view != null)
|
if (view != null)
|
||||||
{
|
{
|
||||||
textBoxName.Text = view.DishName;
|
textBoxName.Text = view.ComponentName;
|
||||||
textBoxCost.Text = view.Cost.ToString();
|
textBoxCost.Text = view.Cost.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,10 +55,10 @@ namespace FoodOrdersView
|
|||||||
_logger.LogInformation("Сохранение блюда");
|
_logger.LogInformation("Сохранение блюда");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var model = new DishBindingModel
|
var model = new ComponentBindingModel
|
||||||
{
|
{
|
||||||
Id = _id ?? 0,
|
Id = _id ?? 0,
|
||||||
DishName = textBoxName.Text,
|
ComponentName = textBoxName.Text,
|
||||||
Cost = Convert.ToDouble(textBoxCost.Text)
|
Cost = Convert.ToDouble(textBoxCost.Text)
|
||||||
};
|
};
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
14
FoodOrders/FoodOrders/FormDishes.Designer.cs
generated
14
FoodOrders/FoodOrders/FormDishes.Designer.cs
generated
@ -1,11 +1,11 @@
|
|||||||
namespace FoodOrdersView
|
namespace FoodOrdersView
|
||||||
{
|
{
|
||||||
partial class FormDishes
|
partial class FormComponents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer Dishes = null;
|
private System.ComponentModel.IContainer Components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
@ -13,9 +13,9 @@
|
|||||||
/// <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 && (Dishes != null))
|
if (disposing && (Components != null))
|
||||||
{
|
{
|
||||||
Dishes.Dispose();
|
Components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@
|
|||||||
this.dataGridView.Size = new System.Drawing.Size(426, 348);
|
this.dataGridView.Size = new System.Drawing.Size(426, 348);
|
||||||
this.dataGridView.TabIndex = 5;
|
this.dataGridView.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// FormDishes
|
// FormComponents
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
@ -103,9 +103,9 @@
|
|||||||
this.Controls.Add(this.buttonDelete);
|
this.Controls.Add(this.buttonDelete);
|
||||||
this.Controls.Add(this.buttonEdit);
|
this.Controls.Add(this.buttonEdit);
|
||||||
this.Controls.Add(this.buttonAdd);
|
this.Controls.Add(this.buttonAdd);
|
||||||
this.Name = "FormDishes";
|
this.Name = "FormComponents";
|
||||||
this.Text = "Блюда";
|
this.Text = "Блюда";
|
||||||
this.Load += new System.EventHandler(this.FormDishes_Load);
|
this.Load += new System.EventHandler(this.FormComponents_Load);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
@ -5,17 +5,17 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace FoodOrdersView
|
namespace FoodOrdersView
|
||||||
{
|
{
|
||||||
public partial class FormDishes : Form
|
public partial class FormComponents : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IDishLogic _logic;
|
private readonly IComponentLogic _logic;
|
||||||
public FormDishes(ILogger<FormDishes> logger, IDishLogic logic)
|
public FormComponents(ILogger<FormComponents> logger, IComponentLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
}
|
}
|
||||||
private void FormDishes_Load(object sender, EventArgs e)
|
private void FormComponents_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ namespace FoodOrdersView
|
|||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
dataGridView.Columns["DishName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Загрузка Блюд");
|
_logger.LogInformation("Загрузка Блюд");
|
||||||
}
|
}
|
||||||
@ -41,8 +41,8 @@ namespace FoodOrdersView
|
|||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormDish));
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||||
if (service is FormDish form)
|
if (service is FormComponent form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@ -54,8 +54,8 @@ namespace FoodOrdersView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormDish));
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||||
if (service is FormDish form)
|
if (service is FormComponent form)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -75,7 +75,7 @@ namespace FoodOrdersView
|
|||||||
_logger.LogInformation("Удаление блюда");
|
_logger.LogInformation("Удаление блюда");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_logic.Delete(new DishBindingModel
|
if (!_logic.Delete(new ComponentBindingModel
|
||||||
{
|
{
|
||||||
Id = id
|
Id = id
|
||||||
}))
|
}))
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
namespace FoodOrdersView
|
namespace FoodOrdersView
|
||||||
{
|
{
|
||||||
partial class FormListSetOfDishes
|
partial class FormListDish
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer Dishes = null;
|
private System.ComponentModel.IContainer Components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
@ -13,9 +13,9 @@
|
|||||||
/// <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 && (Dishes != null))
|
if (disposing && (Components != null))
|
||||||
{
|
{
|
||||||
Dishes.Dispose();
|
Components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@
|
|||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||||
//
|
//
|
||||||
// FormListSetOfDishes
|
// FormListDish
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
@ -103,7 +103,7 @@
|
|||||||
this.Controls.Add(this.buttonDelete);
|
this.Controls.Add(this.buttonDelete);
|
||||||
this.Controls.Add(this.buttonEdit);
|
this.Controls.Add(this.buttonEdit);
|
||||||
this.Controls.Add(this.buttonAdd);
|
this.Controls.Add(this.buttonAdd);
|
||||||
this.Name = "FormListSetOfDishes";
|
this.Name = "FormListDish";
|
||||||
this.Text = "Список набор блюд";
|
this.Text = "Список набор блюд";
|
||||||
this.Load += new System.EventHandler(this.FormDocuments_Load);
|
this.Load += new System.EventHandler(this.FormDocuments_Load);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
@ -5,11 +5,11 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace FoodOrdersView
|
namespace FoodOrdersView
|
||||||
{
|
{
|
||||||
public partial class FormListSetOfDishes : Form
|
public partial class FormListDish : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ISetOfDishesLogic _logic;
|
private readonly IDishLogic _logic;
|
||||||
public FormListSetOfDishes(ILogger<FormListSetOfDishes> logger, ISetOfDishesLogic logic)
|
public FormListDish(ILogger<FormListDish> logger, IDishLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
@ -29,8 +29,8 @@ namespace FoodOrdersView
|
|||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
dataGridView.Columns["SetOfDishesName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["DishName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
dataGridView.Columns["SetOfDishesDishes"].Visible = false;
|
dataGridView.Columns["DishComponents"].Visible = false;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Загрузка набор блюд");
|
_logger.LogInformation("Загрузка набор блюд");
|
||||||
}
|
}
|
||||||
@ -43,8 +43,8 @@ namespace FoodOrdersView
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSetOfDishes));
|
var service = Program.ServiceProvider?.GetService(typeof(FormDish));
|
||||||
if (service is FormSetOfDishes form)
|
if (service is FormDish form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@ -57,8 +57,8 @@ namespace FoodOrdersView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSetOfDishes));
|
var service = Program.ServiceProvider?.GetService(typeof(FormDish));
|
||||||
if (service is FormSetOfDishes form)
|
if (service is FormDish form)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -79,7 +79,7 @@ namespace FoodOrdersView
|
|||||||
_logger.LogInformation("Удаление набор блюд");
|
_logger.LogInformation("Удаление набор блюд");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_logic.Delete(new SetOfDishesBindingModel
|
if (!_logic.Delete(new DishBindingModel
|
||||||
{
|
{
|
||||||
Id = id
|
Id = id
|
||||||
}))
|
}))
|
||||||
|
10
FoodOrders/FoodOrders/FormMain.Designer.cs
generated
10
FoodOrders/FoodOrders/FormMain.Designer.cs
generated
@ -5,7 +5,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer Dishes = null;
|
private System.ComponentModel.IContainer Components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
@ -13,9 +13,9 @@
|
|||||||
/// <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 && (Dishes != null))
|
if (disposing && (Components != null))
|
||||||
{
|
{
|
||||||
Dishes.Dispose();
|
Components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
@ -66,14 +66,14 @@
|
|||||||
this.БлюдаToolStripMenuItem.Name = "БлюдаToolStripMenuItem";
|
this.БлюдаToolStripMenuItem.Name = "БлюдаToolStripMenuItem";
|
||||||
this.БлюдаToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
|
this.БлюдаToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
|
||||||
this.БлюдаToolStripMenuItem.Text = "Блюда";
|
this.БлюдаToolStripMenuItem.Text = "Блюда";
|
||||||
this.БлюдаToolStripMenuItem.Click += new System.EventHandler(this.DishesToolStripMenuItem_Click);
|
this.БлюдаToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// набор блюдToolStripMenuItem
|
// набор блюдToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.наборблюдToolStripMenuItem.Name = "набор блюдToolStripMenuItem";
|
this.наборблюдToolStripMenuItem.Name = "набор блюдToolStripMenuItem";
|
||||||
this.наборблюдToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
|
this.наборблюдToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
|
||||||
this.наборблюдToolStripMenuItem.Text = "Набор блюд";
|
this.наборблюдToolStripMenuItem.Text = "Набор блюд";
|
||||||
this.наборблюдToolStripMenuItem.Click += new System.EventHandler(this.SetOfDishesToolStripMenuItem_Click);
|
this.наборблюдToolStripMenuItem.Click += new System.EventHandler(this.DishToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// buttonUpdate
|
// buttonUpdate
|
||||||
//
|
//
|
||||||
|
@ -30,7 +30,7 @@ namespace FoodOrdersView
|
|||||||
if (list != null)
|
if (list != null)
|
||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["SetOfDishesId"].Visible = false;
|
dataGridView.Columns["DishId"].Visible = false;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
@ -40,18 +40,18 @@ namespace FoodOrdersView
|
|||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void DishesToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormDishes));
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||||
if (service is FormDishes form)
|
if (service is FormComponents form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void SetOfDishesToolStripMenuItem_Click(object sender, EventArgs e)
|
private void DishToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormListSetOfDishes));
|
var service = Program.ServiceProvider?.GetService(typeof(FormListDish));
|
||||||
if (service is FormListSetOfDishes form)
|
if (service is FormListDish form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
@ -76,8 +76,8 @@ namespace FoodOrdersView
|
|||||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
SetOfDishesId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SetOfDishesId"].Value),
|
DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value),
|
||||||
SetOfDishesName = dataGridView.SelectedRows[0].Cells["SetOfDishesName"].Value.ToString(),
|
DishName = dataGridView.SelectedRows[0].Cells["DishName"].Value.ToString(),
|
||||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||||
@ -107,8 +107,8 @@ namespace FoodOrdersView
|
|||||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
SetOfDishesId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SetOfDishesId"].Value),
|
DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value),
|
||||||
SetOfDishesName = dataGridView.SelectedRows[0].Cells["SetOfDishesName"].Value.ToString(),
|
DishName = dataGridView.SelectedRows[0].Cells["DishName"].Value.ToString(),
|
||||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||||
@ -138,8 +138,8 @@ namespace FoodOrdersView
|
|||||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
SetOfDishesId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SetOfDishesId"].Value),
|
DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value),
|
||||||
SetOfDishesName = dataGridView.SelectedRows[0].Cells["SetOfDishesName"].Value.ToString(),
|
DishName = dataGridView.SelectedRows[0].Cells["DishName"].Value.ToString(),
|
||||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||||
|
78
FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs
generated
78
FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs
generated
@ -1,11 +1,11 @@
|
|||||||
namespace FoodOrdersView
|
namespace FoodOrdersView
|
||||||
{
|
{
|
||||||
partial class FormSetOfDishes
|
partial class FormDish
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer Dishes = null;
|
private System.ComponentModel.IContainer Components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
@ -13,9 +13,9 @@
|
|||||||
/// <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 && (Dishes != null))
|
if (disposing && (Components != null))
|
||||||
{
|
{
|
||||||
Dishes.Dispose();
|
Components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@
|
|||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
this.labelPrice = new System.Windows.Forms.Label();
|
this.labelPrice = new System.Windows.Forms.Label();
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
this.labelName = new System.Windows.Forms.Label();
|
||||||
this.groupBoxDishes = new System.Windows.Forms.GroupBox();
|
this.groupBoxComponents = new System.Windows.Forms.GroupBox();
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||||
@ -41,9 +41,9 @@
|
|||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.ColumnDishName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.ColumnComponentName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.groupBoxDishes.SuspendLayout();
|
this.groupBoxComponents.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -81,24 +81,24 @@
|
|||||||
this.labelName.TabIndex = 4;
|
this.labelName.TabIndex = 4;
|
||||||
this.labelName.Text = "Название:";
|
this.labelName.Text = "Название:";
|
||||||
//
|
//
|
||||||
// groupBoxDishes
|
// groupBoxComponents
|
||||||
//
|
//
|
||||||
this.groupBoxDishes.Controls.Add(this.buttonCancel);
|
this.groupBoxComponents.Controls.Add(this.buttonCancel);
|
||||||
this.groupBoxDishes.Controls.Add(this.buttonSave);
|
this.groupBoxComponents.Controls.Add(this.buttonSave);
|
||||||
this.groupBoxDishes.Controls.Add(this.buttonUpdate);
|
this.groupBoxComponents.Controls.Add(this.buttonUpdate);
|
||||||
this.groupBoxDishes.Controls.Add(this.buttonDelete);
|
this.groupBoxComponents.Controls.Add(this.buttonDelete);
|
||||||
this.groupBoxDishes.Controls.Add(this.buttonEdit);
|
this.groupBoxComponents.Controls.Add(this.buttonEdit);
|
||||||
this.groupBoxDishes.Controls.Add(this.buttonAdd);
|
this.groupBoxComponents.Controls.Add(this.buttonAdd);
|
||||||
this.groupBoxDishes.Controls.Add(this.dataGridView);
|
this.groupBoxComponents.Controls.Add(this.dataGridView);
|
||||||
this.groupBoxDishes.Dock = System.Windows.Forms.DockStyle.Bottom;
|
this.groupBoxComponents.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
this.groupBoxDishes.Location = new System.Drawing.Point(0, 70);
|
this.groupBoxComponents.Location = new System.Drawing.Point(0, 70);
|
||||||
this.groupBoxDishes.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
this.groupBoxComponents.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
this.groupBoxDishes.Name = "groupBoxDishes";
|
this.groupBoxComponents.Name = "groupBoxComponents";
|
||||||
this.groupBoxDishes.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
this.groupBoxComponents.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
this.groupBoxDishes.Size = new System.Drawing.Size(592, 206);
|
this.groupBoxComponents.Size = new System.Drawing.Size(592, 206);
|
||||||
this.groupBoxDishes.TabIndex = 8;
|
this.groupBoxComponents.TabIndex = 8;
|
||||||
this.groupBoxDishes.TabStop = false;
|
this.groupBoxComponents.TabStop = false;
|
||||||
this.groupBoxDishes.Text = "Компоненты";
|
this.groupBoxComponents.Text = "Компоненты";
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
@ -171,7 +171,7 @@
|
|||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
this.ID,
|
this.ID,
|
||||||
this.ColumnDishName,
|
this.ColumnComponentName,
|
||||||
this.ColumnCount});
|
this.ColumnCount});
|
||||||
this.dataGridView.Location = new System.Drawing.Point(5, 20);
|
this.dataGridView.Location = new System.Drawing.Point(5, 20);
|
||||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
@ -189,14 +189,14 @@
|
|||||||
this.ID.Visible = false;
|
this.ID.Visible = false;
|
||||||
this.ID.Width = 125;
|
this.ID.Width = 125;
|
||||||
//
|
//
|
||||||
// ColumnDishName
|
// ColumnComponentName
|
||||||
//
|
//
|
||||||
this.ColumnDishName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
|
this.ColumnComponentName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
|
||||||
this.ColumnDishName.HeaderText = "Блюдо";
|
this.ColumnComponentName.HeaderText = "Блюдо";
|
||||||
this.ColumnDishName.MinimumWidth = 6;
|
this.ColumnComponentName.MinimumWidth = 6;
|
||||||
this.ColumnDishName.Name = "ColumnDishName";
|
this.ColumnComponentName.Name = "ColumnComponentName";
|
||||||
this.ColumnDishName.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
this.ColumnComponentName.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
||||||
this.ColumnDishName.Width = 312;
|
this.ColumnComponentName.Width = 312;
|
||||||
//
|
//
|
||||||
// ColumnCount
|
// ColumnCount
|
||||||
//
|
//
|
||||||
@ -205,20 +205,20 @@
|
|||||||
this.ColumnCount.Name = "ColumnCount";
|
this.ColumnCount.Name = "ColumnCount";
|
||||||
this.ColumnCount.Width = 125;
|
this.ColumnCount.Width = 125;
|
||||||
//
|
//
|
||||||
// FormSetOfDishes
|
// FormDish
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(592, 276);
|
this.ClientSize = new System.Drawing.Size(592, 276);
|
||||||
this.Controls.Add(this.groupBoxDishes);
|
this.Controls.Add(this.groupBoxComponents);
|
||||||
this.Controls.Add(this.textBoxPrice);
|
this.Controls.Add(this.textBoxPrice);
|
||||||
this.Controls.Add(this.textBoxName);
|
this.Controls.Add(this.textBoxName);
|
||||||
this.Controls.Add(this.labelPrice);
|
this.Controls.Add(this.labelPrice);
|
||||||
this.Controls.Add(this.labelName);
|
this.Controls.Add(this.labelName);
|
||||||
this.Name = "FormSetOfDishes";
|
this.Name = "FormDish";
|
||||||
this.Text = "Набор блюд";
|
this.Text = "Набор блюд";
|
||||||
this.Load += new System.EventHandler(this.FormSetOfDishes_Load);
|
this.Load += new System.EventHandler(this.FormDish_Load);
|
||||||
this.groupBoxDishes.ResumeLayout(false);
|
this.groupBoxComponents.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
@ -231,7 +231,7 @@
|
|||||||
private TextBox textBoxName;
|
private TextBox textBoxName;
|
||||||
private Label labelPrice;
|
private Label labelPrice;
|
||||||
private Label labelName;
|
private Label labelName;
|
||||||
private GroupBox groupBoxDishes;
|
private GroupBox groupBoxComponents;
|
||||||
private Button buttonUpdate;
|
private Button buttonUpdate;
|
||||||
private Button buttonDelete;
|
private Button buttonDelete;
|
||||||
private Button buttonEdit;
|
private Button buttonEdit;
|
||||||
@ -240,7 +240,7 @@
|
|||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private DataGridViewTextBoxColumn ID;
|
private DataGridViewTextBoxColumn ID;
|
||||||
private DataGridViewTextBoxColumn ColumnDishName;
|
private DataGridViewTextBoxColumn ColumnComponentName;
|
||||||
private DataGridViewTextBoxColumn ColumnCount;
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,36 +7,36 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace FoodOrdersView
|
namespace FoodOrdersView
|
||||||
{
|
{
|
||||||
public partial class FormSetOfDishes : Form
|
public partial class FormDish : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ISetOfDishesLogic _logic;
|
private readonly IDishLogic _logic;
|
||||||
private int? _id;
|
private int? _id;
|
||||||
private Dictionary<int, (IDishModel, int)> _set_of_dishesDishes;
|
private Dictionary<int, (IComponentModel, int)> _dishComponents;
|
||||||
public int Id { set { _id = value; } }
|
public int Id { set { _id = value; } }
|
||||||
public FormSetOfDishes(ILogger<FormSetOfDishes> logger, ISetOfDishesLogic logic)
|
public FormDish(ILogger<FormDish> logger, IDishLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
_set_of_dishesDishes = new Dictionary<int, (IDishModel, int)>();
|
_dishComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||||
}
|
}
|
||||||
private void FormSetOfDishes_Load(object sender, EventArgs e)
|
private void FormDish_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_id.HasValue)
|
if (_id.HasValue)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Загрузка набор блюд");
|
_logger.LogInformation("Загрузка набор блюд");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var view = _logic.ReadElement(new SetOfDishesearchModel
|
var view = _logic.ReadElement(new DishSearchModel
|
||||||
{
|
{
|
||||||
Id = _id.Value
|
Id = _id.Value
|
||||||
});
|
});
|
||||||
if (view != null)
|
if (view != null)
|
||||||
{
|
{
|
||||||
textBoxName.Text = view.SetOfDishesName;
|
textBoxName.Text = view.DishName;
|
||||||
textBoxPrice.Text = view.Price.ToString();
|
textBoxPrice.Text = view.Price.ToString();
|
||||||
_set_of_dishesDishes = view.SetOfDishesDishes ?? new Dictionary<int, (IDishModel, int)>();
|
_dishComponents = view.DishComponents ?? new Dictionary<int, (IComponentModel, int)>();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,12 +53,12 @@ namespace FoodOrdersView
|
|||||||
_logger.LogInformation("Загрузка Блюдо набор блюд");
|
_logger.LogInformation("Загрузка Блюдо набор блюд");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_set_of_dishesDishes != null)
|
if (_dishComponents != null)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Clear();
|
dataGridView.Rows.Clear();
|
||||||
foreach (var sc in _set_of_dishesDishes)
|
foreach (var sc in _dishComponents)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Add(new object[] { sc.Key, sc.Value.Item1.DishName, sc.Value.Item2 });
|
dataGridView.Rows.Add(new object[] { sc.Key, sc.Value.Item1.ComponentName, sc.Value.Item2 });
|
||||||
}
|
}
|
||||||
textBoxPrice.Text = CalcPrice().ToString();
|
textBoxPrice.Text = CalcPrice().ToString();
|
||||||
}
|
}
|
||||||
@ -71,8 +71,8 @@ namespace FoodOrdersView
|
|||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSetOfDishesDishes));
|
var service = Program.ServiceProvider?.GetService(typeof(FormDishComponents));
|
||||||
if (service is FormSetOfDishesDishes form)
|
if (service is FormDishComponents form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@ -80,15 +80,15 @@ namespace FoodOrdersView
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Добавление нового блюда: { DishName} - { Count}", form.ComponentModel.DishName, form.Count);
|
_logger.LogInformation("Добавление нового блюда: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||||
if (_set_of_dishesDishes.ContainsKey(form.Id))
|
if (_dishComponents.ContainsKey(form.Id))
|
||||||
{
|
{
|
||||||
_set_of_dishesDishes[form.Id] = (form.ComponentModel,
|
_dishComponents[form.Id] = (form.ComponentModel,
|
||||||
form.Count);
|
form.Count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_set_of_dishesDishes.Add(form.Id, (form.ComponentModel,
|
_dishComponents.Add(form.Id, (form.ComponentModel,
|
||||||
form.Count));
|
form.Count));
|
||||||
}
|
}
|
||||||
LoadData();
|
LoadData();
|
||||||
@ -99,21 +99,21 @@ namespace FoodOrdersView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSetOfDishesDishes));
|
var service = Program.ServiceProvider?.GetService(typeof(FormDishComponents));
|
||||||
if (service is FormSetOfDishesDishes form)
|
if (service is FormDishComponents form)
|
||||||
{
|
{
|
||||||
int id =
|
int id =
|
||||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
form.Id = id;
|
form.Id = id;
|
||||||
form.Count = _set_of_dishesDishes[id].Item2;
|
form.Count = _dishComponents[id].Item2;
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (form.ComponentModel == null)
|
if (form.ComponentModel == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Изменение блюда: { DishName} - { Count} ", form.ComponentModel.DishName, form.Count);
|
_logger.LogInformation("Изменение блюда: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count);
|
||||||
_set_of_dishesDishes[form.Id] = (form.ComponentModel, form.Count);
|
_dishComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,8 +128,8 @@ namespace FoodOrdersView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Удаление блюда: { DishName} - { Count} ",
|
_logger.LogInformation("Удаление блюда: { ComponentName} - { Count} ",
|
||||||
dataGridView.SelectedRows[0].Cells[1].Value); _set_of_dishesDishes?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
dataGridView.SelectedRows[0].Cells[1].Value); _dishComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -158,7 +158,7 @@ namespace FoodOrdersView
|
|||||||
MessageBoxIcon.Error);
|
MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_set_of_dishesDishes == null || _set_of_dishesDishes.Count == 0)
|
if (_dishComponents == null || _dishComponents.Count == 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Заполните Блюда", "Ошибка",
|
MessageBox.Show("Заполните Блюда", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
@ -167,12 +167,12 @@ namespace FoodOrdersView
|
|||||||
_logger.LogInformation("Сохранение набор блюд");
|
_logger.LogInformation("Сохранение набор блюд");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var model = new SetOfDishesBindingModel
|
var model = new DishBindingModel
|
||||||
{
|
{
|
||||||
Id = _id ?? 0,
|
Id = _id ?? 0,
|
||||||
SetOfDishesName = textBoxName.Text,
|
DishName = textBoxName.Text,
|
||||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
Price = Convert.ToDouble(textBoxPrice.Text),
|
||||||
SetOfDishesDishes = _set_of_dishesDishes
|
DishComponents = _dishComponents
|
||||||
};
|
};
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
@ -197,7 +197,7 @@ namespace FoodOrdersView
|
|||||||
private double CalcPrice()
|
private double CalcPrice()
|
||||||
{
|
{
|
||||||
double price = 0;
|
double price = 0;
|
||||||
foreach (var elem in _set_of_dishesDishes)
|
foreach (var elem in _dishComponents)
|
||||||
{
|
{
|
||||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="ColumnDishName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="ColumnComponentName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
namespace FoodOrdersView
|
namespace FoodOrdersView
|
||||||
{
|
{
|
||||||
partial class FormSetOfDishesDishes
|
partial class FormDishComponents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer Dishes = null;
|
private System.ComponentModel.IContainer Components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
@ -13,9 +13,9 @@
|
|||||||
/// <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 && (Dishes != null))
|
if (disposing && (Components != null))
|
||||||
{
|
{
|
||||||
Dishes.Dispose();
|
Components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
@ -31,9 +31,9 @@
|
|||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
this.comboBoxDish = new System.Windows.Forms.ComboBox();
|
this.comboBoxComponent = new System.Windows.Forms.ComboBox();
|
||||||
this.labelCount = new System.Windows.Forms.Label();
|
this.labelCount = new System.Windows.Forms.Label();
|
||||||
this.labelDish = new System.Windows.Forms.Label();
|
this.labelComponent = new System.Windows.Forms.Label();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
@ -66,14 +66,14 @@
|
|||||||
this.textBoxCount.Size = new System.Drawing.Size(283, 23);
|
this.textBoxCount.Size = new System.Drawing.Size(283, 23);
|
||||||
this.textBoxCount.TabIndex = 9;
|
this.textBoxCount.TabIndex = 9;
|
||||||
//
|
//
|
||||||
// comboBoxDish
|
// comboBoxComponent
|
||||||
//
|
//
|
||||||
this.comboBoxDish.FormattingEnabled = true;
|
this.comboBoxComponent.FormattingEnabled = true;
|
||||||
this.comboBoxDish.Location = new System.Drawing.Point(116, 11);
|
this.comboBoxComponent.Location = new System.Drawing.Point(116, 11);
|
||||||
this.comboBoxDish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
this.comboBoxComponent.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
this.comboBoxDish.Name = "comboBoxDish";
|
this.comboBoxComponent.Name = "comboBoxComponent";
|
||||||
this.comboBoxDish.Size = new System.Drawing.Size(282, 23);
|
this.comboBoxComponent.Size = new System.Drawing.Size(282, 23);
|
||||||
this.comboBoxDish.TabIndex = 8;
|
this.comboBoxComponent.TabIndex = 8;
|
||||||
//
|
//
|
||||||
// labelCount
|
// labelCount
|
||||||
//
|
//
|
||||||
@ -84,16 +84,16 @@
|
|||||||
this.labelCount.TabIndex = 7;
|
this.labelCount.TabIndex = 7;
|
||||||
this.labelCount.Text = "Количество:";
|
this.labelCount.Text = "Количество:";
|
||||||
//
|
//
|
||||||
// labelDish
|
// labelComponent
|
||||||
//
|
//
|
||||||
this.labelDish.AutoSize = true;
|
this.labelComponent.AutoSize = true;
|
||||||
this.labelDish.Location = new System.Drawing.Point(10, 14);
|
this.labelComponent.Location = new System.Drawing.Point(10, 14);
|
||||||
this.labelDish.Name = "labelDish";
|
this.labelComponent.Name = "labelComponent";
|
||||||
this.labelDish.Size = new System.Drawing.Size(75, 15);
|
this.labelComponent.Size = new System.Drawing.Size(75, 15);
|
||||||
this.labelDish.TabIndex = 6;
|
this.labelComponent.TabIndex = 6;
|
||||||
this.labelDish.Text = "Блюдо:";
|
this.labelComponent.Text = "Блюдо:";
|
||||||
//
|
//
|
||||||
// FormSetOfDishesDishes
|
// FormDishComponents
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
@ -101,10 +101,10 @@
|
|||||||
this.Controls.Add(this.buttonCancel);
|
this.Controls.Add(this.buttonCancel);
|
||||||
this.Controls.Add(this.buttonSave);
|
this.Controls.Add(this.buttonSave);
|
||||||
this.Controls.Add(this.textBoxCount);
|
this.Controls.Add(this.textBoxCount);
|
||||||
this.Controls.Add(this.comboBoxDish);
|
this.Controls.Add(this.comboBoxComponent);
|
||||||
this.Controls.Add(this.labelCount);
|
this.Controls.Add(this.labelCount);
|
||||||
this.Controls.Add(this.labelDish);
|
this.Controls.Add(this.labelComponent);
|
||||||
this.Name = "FormSetOfDishesDishes";
|
this.Name = "FormDishComponents";
|
||||||
this.Text = "Блюдо набор блюд";
|
this.Text = "Блюдо набор блюд";
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
@ -116,8 +116,8 @@
|
|||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private TextBox textBoxCount;
|
private TextBox textBoxCount;
|
||||||
private ComboBox comboBoxDish;
|
private ComboBox comboBoxComponent;
|
||||||
private Label labelCount;
|
private Label labelCount;
|
||||||
private Label labelDish;
|
private Label labelComponent;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,21 +4,21 @@ using FoodOrdersDataModels.Models;
|
|||||||
|
|
||||||
namespace FoodOrdersView
|
namespace FoodOrdersView
|
||||||
{
|
{
|
||||||
public partial class FormSetOfDishesDishes : Form
|
public partial class FormDishComponents : Form
|
||||||
{
|
{
|
||||||
private readonly List<DishViewModel>? _list;
|
private readonly List<ComponentViewModel>? _list;
|
||||||
public int Id
|
public int Id
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Convert.ToInt32(comboBoxDish.SelectedValue);
|
return Convert.ToInt32(comboBoxComponent.SelectedValue);
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
comboBoxDish.SelectedValue = value;
|
comboBoxComponent.SelectedValue = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public IDishModel? ComponentModel
|
public IComponentModel? ComponentModel
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -41,16 +41,16 @@ namespace FoodOrdersView
|
|||||||
get { return Convert.ToInt32(textBoxCount.Text); }
|
get { return Convert.ToInt32(textBoxCount.Text); }
|
||||||
set { textBoxCount.Text = value.ToString(); }
|
set { textBoxCount.Text = value.ToString(); }
|
||||||
}
|
}
|
||||||
public FormSetOfDishesDishes(IDishLogic logic)
|
public FormDishComponents(IComponentLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_list = logic.ReadList(null);
|
_list = logic.ReadList(null);
|
||||||
if (_list != null)
|
if (_list != null)
|
||||||
{
|
{
|
||||||
comboBoxDish.DisplayMember = "DishName";
|
comboBoxComponent.DisplayMember = "ComponentName";
|
||||||
comboBoxDish.ValueMember = "Id";
|
comboBoxComponent.ValueMember = "Id";
|
||||||
comboBoxDish.DataSource = _list;
|
comboBoxComponent.DataSource = _list;
|
||||||
comboBoxDish.SelectedItem = null;
|
comboBoxComponent.SelectedItem = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
@ -61,7 +61,7 @@ namespace FoodOrdersView
|
|||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (comboBoxDish.SelectedValue == null)
|
if (comboBoxComponent.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите Блюдо", "Ошибка",
|
MessageBox.Show("Выберите Блюдо", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
@ -37,19 +37,19 @@ namespace FoodOrders
|
|||||||
option.SetMinimumLevel(LogLevel.Information);
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
option.AddNLog("nlog.config");
|
option.AddNLog("nlog.config");
|
||||||
});
|
});
|
||||||
services.AddTransient<IDishestorage, Dishestorage>();
|
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
services.AddTransient<ISetOfDishestorage, SetOfDishestorage>();
|
services.AddTransient<IDishStorage, DishStorage>();
|
||||||
services.AddTransient<IDishLogic, DishLogic>();
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<ISetOfDishesLogic, SetOfDishesLogic>();
|
services.AddTransient<IDishLogic, DishLogic>();
|
||||||
services.AddTransient<FormMain>();
|
services.AddTransient<FormMain>();
|
||||||
services.AddTransient<FormDish>();
|
services.AddTransient<FormComponent>();
|
||||||
services.AddTransient<FormDishes>();
|
services.AddTransient<FormComponents>();
|
||||||
services.AddTransient<FormCreateOrder>();
|
services.AddTransient<FormCreateOrder>();
|
||||||
services.AddTransient<FormSetOfDishes>();
|
services.AddTransient<FormDish>();
|
||||||
services.AddTransient<FormSetOfDishesDishes>();
|
services.AddTransient<FormDishComponents>();
|
||||||
services.AddTransient<FormListSetOfDishes>();
|
services.AddTransient<FormListDish>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,30 +4,25 @@ using FoodOrdersContracts.SearchModels;
|
|||||||
using FoodOrdersContracts.StoragesContracts;
|
using FoodOrdersContracts.StoragesContracts;
|
||||||
using FoodOrdersContracts.ViewModels;
|
using FoodOrdersContracts.ViewModels;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FoodOrdersBusinessLogic.BusinessLogics
|
namespace FoodOrdersBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class SetOfDishesLogic : ISetOfDishesLogic
|
public class ComponentLogic : IComponentLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ISetOfDishestorage _set_of_dishesStorage;
|
private readonly IComponentStorage _componentStorage;
|
||||||
public SetOfDishesLogic(ILogger<SetOfDishesLogic> logger, ISetOfDishestorage set_of_dishesStorage)
|
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage
|
||||||
|
ComponentStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_set_of_dishesStorage = set_of_dishesStorage;
|
_componentStorage = ComponentStorage;
|
||||||
}
|
}
|
||||||
|
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
|
||||||
public List<SetOfDishesViewModel>? ReadList(SetOfDishesearchModel? model)
|
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. SetOfDishesName:{SetOfDishesName}. Id:{Id}",
|
_logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{Id}",
|
||||||
model?.SetOfDishesName, model?.Id);
|
model?.ComponentName, model?.Id);
|
||||||
var list = model == null ? _set_of_dishesStorage.GetFullList() :
|
var list = model == null ? _componentStorage.GetFullList() :
|
||||||
_set_of_dishesStorage.GetFilteredList(model);
|
_componentStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
@ -36,15 +31,14 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
public ComponentViewModel? ReadElement(ComponentSearchModel model)
|
||||||
public SetOfDishesViewModel? ReadElement(SetOfDishesearchModel model)
|
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. SetOfDishesName:{SetOfDishesName}. Id:{Id}", model.SetOfDishesName, model.Id);
|
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{Id}", model.ComponentName, model.Id);
|
||||||
var element = _set_of_dishesStorage.GetElement(model);
|
var element = _componentStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
@ -53,40 +47,39 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
public bool Create(ComponentBindingModel model)
|
||||||
public bool Create(SetOfDishesBindingModel model)
|
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_set_of_dishesStorage.Insert(model) == null)
|
if (_componentStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
public bool Update(ComponentBindingModel model)
|
||||||
public bool Update(SetOfDishesBindingModel model)
|
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_set_of_dishesStorage.Update(model) == null)
|
if (_componentStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public bool Delete(SetOfDishesBindingModel model)
|
public bool Delete(ComponentBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
if (_set_of_dishesStorage.Delete(model) == null)
|
if (_componentStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private void CheckModel(SetOfDishesBindingModel model, bool withParams = true)
|
private void CheckModel(ComponentBindingModel model, bool withParams =
|
||||||
|
true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -96,22 +89,23 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.SetOfDishesName))
|
if (string.IsNullOrEmpty(model.ComponentName))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет названия компонента", nameof(model.SetOfDishesName));
|
throw new ArgumentNullException("Нет названия компонента",
|
||||||
|
nameof(model.ComponentName));
|
||||||
}
|
}
|
||||||
if (model.Price <= 0)
|
if (model.Cost <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Price));
|
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("SetOfDishes. SetOfDishesName:{SetOfDishesName}. Price:{Price}. Id:{Id}", model.SetOfDishesName, model.Price, model.Id);
|
_logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. Id:{Id}", model.ComponentName, model.Cost, model.Id);
|
||||||
var element = _set_of_dishesStorage.GetElement(new SetOfDishesearchModel
|
var element = _componentStorage.GetElement(new ComponentSearchModel
|
||||||
{
|
{
|
||||||
SetOfDishesName = model.SetOfDishesName
|
ComponentName = model.ComponentName
|
||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Прдукт с таким названием уже есть");
|
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,25 +4,30 @@ using FoodOrdersContracts.SearchModels;
|
|||||||
using FoodOrdersContracts.StoragesContracts;
|
using FoodOrdersContracts.StoragesContracts;
|
||||||
using FoodOrdersContracts.ViewModels;
|
using FoodOrdersContracts.ViewModels;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FoodOrdersBusinessLogic.BusinessLogics
|
namespace FoodOrdersBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class DishLogic : IDishLogic
|
public class DishLogic : IDishLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IDishestorage _Dishestorage;
|
private readonly IDishStorage _dishStorage;
|
||||||
public DishLogic(ILogger<DishLogic> logger, IDishestorage
|
public DishLogic(ILogger<DishLogic> logger, IDishStorage dishStorage)
|
||||||
Dishestorage)
|
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_Dishestorage = Dishestorage;
|
_dishStorage = dishStorage;
|
||||||
}
|
}
|
||||||
public List<DishViewModel>? ReadList(DishesearchModel? model)
|
|
||||||
|
public List<DishViewModel>? ReadList(DishSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. DishName:{DishName}. Id:{Id}",
|
_logger.LogInformation("ReadList. DishName:{DishName}. Id:{Id}",
|
||||||
model?.DishName, model?.Id);
|
model?.DishName, model?.Id);
|
||||||
var list = model == null ? _Dishestorage.GetFullList() :
|
var list = model == null ? _dishStorage.GetFullList() :
|
||||||
_Dishestorage.GetFilteredList(model);
|
_dishStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
@ -31,14 +36,15 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
public DishViewModel? ReadElement(DishesearchModel model)
|
|
||||||
|
public DishViewModel? ReadElement(DishSearchModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. DishName:{DishName}. Id:{Id}", model.DishName, model.Id);
|
_logger.LogInformation("ReadElement. DishName:{DishName}. Id:{Id}", model.DishName, model.Id);
|
||||||
var element = _Dishestorage.GetElement(model);
|
var element = _dishStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
@ -47,20 +53,22 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Create(DishBindingModel model)
|
public bool Create(DishBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_Dishestorage.Insert(model) == null)
|
if (_dishStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(DishBindingModel model)
|
public bool Update(DishBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_Dishestorage.Update(model) == null)
|
if (_dishStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -71,15 +79,14 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
if (_Dishestorage.Delete(model) == null)
|
if (_dishStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private void CheckModel(DishBindingModel model, bool withParams =
|
private void CheckModel(DishBindingModel model, bool withParams = true)
|
||||||
true)
|
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -91,21 +98,20 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.DishName))
|
if (string.IsNullOrEmpty(model.DishName))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет названия компонента",
|
throw new ArgumentNullException("Нет названия компонента", nameof(model.DishName));
|
||||||
nameof(model.DishName));
|
|
||||||
}
|
}
|
||||||
if (model.Cost <= 0)
|
if (model.Price <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Price));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Dish. DishName:{DishName}. Cost:{ Cost}. Id:{Id}", model.DishName, model.Cost, model.Id);
|
_logger.LogInformation("Dish. DishName:{DishName}. Price:{Price}. Id:{Id}", model.DishName, model.Price, model.Id);
|
||||||
var element = _Dishestorage.GetElement(new DishesearchModel
|
var element = _dishStorage.GetElement(new DishSearchModel
|
||||||
{
|
{
|
||||||
DishName = model.DishName
|
DishName = model.DishName
|
||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
throw new InvalidOperationException("Прдукт с таким названием уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. DishName:{DishName}. Id:{Id}", model?.Id);
|
_logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{Id}", model?.Id);
|
||||||
var list = model == null ? _orderStorage.GetFullList() :
|
var list = model == null ? _orderStorage.GetFullList() :
|
||||||
_orderStorage.GetFilteredList(model);
|
_orderStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
@ -87,7 +87,7 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Order. OrderID:{Id}. Sum:{ Sum}. SetOfDishesId: { SetOfDishesId}", model.Id, model.Sum, model.Id);
|
_logger.LogInformation("Order. OrderID:{Id}. Sum:{ Sum}. DishId: { DishId}", model.Id, model.Sum, model.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//???
|
//???
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
using FoodOrdersDataModels.Models;
|
||||||
|
|
||||||
|
namespace FoodOrdersContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ComponentBindingModel : IComponentModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
|
public double Cost { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,11 @@ namespace FoodOrdersContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string DishName { get; set; } = string.Empty;
|
public string DishName { get; set; } = string.Empty;
|
||||||
public double Cost { get; set; }
|
public double Price { get; set; }
|
||||||
|
public Dictionary<int, (IComponentModel, int)> DishComponents
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,8 +6,8 @@ namespace FoodOrdersContracts.BindingModels
|
|||||||
public class OrderBindingModel : IOrderModel
|
public class OrderBindingModel : IOrderModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int SetOfDishesId { get; set; }
|
public int DishId { get; set; }
|
||||||
public string SetOfDishesName { get; set; } = string.Empty;
|
public string DishName { get; set; } = string.Empty;
|
||||||
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.Неизвестен;
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
using FoodOrdersDataModels.Models;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class SetOfDishesBindingModel : ISetOfDishesModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string SetOfDishesName { get; set; } = string.Empty;
|
|
||||||
public double Price { get; set; }
|
|
||||||
public Dictionary<int, (IDishModel, int)> SetOfDishesDishes
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
} = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,15 @@
|
|||||||
|
using FoodOrdersContracts.BindingModels;
|
||||||
|
using FoodOrdersContracts.SearchModels;
|
||||||
|
using FoodOrdersContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace FoodOrdersContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IComponentLogic
|
||||||
|
{
|
||||||
|
List<ComponentViewModel>? ReadList(ComponentSearchModel? model);
|
||||||
|
ComponentViewModel? ReadElement(ComponentSearchModel model);
|
||||||
|
bool Create(ComponentBindingModel model);
|
||||||
|
bool Update(ComponentBindingModel model);
|
||||||
|
bool Delete(ComponentBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -6,8 +6,8 @@ namespace FoodOrdersContracts.BusinessLogicsContracts
|
|||||||
{
|
{
|
||||||
public interface IDishLogic
|
public interface IDishLogic
|
||||||
{
|
{
|
||||||
List<DishViewModel>? ReadList(DishesearchModel? model);
|
List<DishViewModel>? ReadList(DishSearchModel? model);
|
||||||
DishViewModel? ReadElement(DishesearchModel model);
|
DishViewModel? ReadElement(DishSearchModel model);
|
||||||
bool Create(DishBindingModel model);
|
bool Create(DishBindingModel model);
|
||||||
bool Update(DishBindingModel model);
|
bool Update(DishBindingModel model);
|
||||||
bool Delete(DishBindingModel model);
|
bool Delete(DishBindingModel model);
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface ISetOfDishesLogic
|
|
||||||
{
|
|
||||||
List<SetOfDishesViewModel>? ReadList(SetOfDishesearchModel? model);
|
|
||||||
SetOfDishesViewModel? ReadElement(SetOfDishesearchModel model);
|
|
||||||
bool Create(SetOfDishesBindingModel model);
|
|
||||||
bool Update(SetOfDishesBindingModel model);
|
|
||||||
bool Delete(SetOfDishesBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
namespace FoodOrdersContracts.SearchModels
|
namespace FoodOrdersContracts.SearchModels
|
||||||
{
|
{
|
||||||
public class SetOfDishesearchModel
|
public class ComponentSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? SetOfDishesName { get; set; }
|
public string? ComponentName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
namespace FoodOrdersContracts.SearchModels
|
namespace FoodOrdersContracts.SearchModels
|
||||||
{
|
{
|
||||||
public class DishesearchModel
|
public class DishSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? DishName { get; set; }
|
public string? DishName { get; set; }
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
using FoodOrdersContracts.BindingModels;
|
||||||
|
using FoodOrdersContracts.SearchModels;
|
||||||
|
using FoodOrdersContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace FoodOrdersContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IComponentStorage
|
||||||
|
{
|
||||||
|
List<ComponentViewModel> GetFullList();
|
||||||
|
List<ComponentViewModel> GetFilteredList(ComponentSearchModel model);
|
||||||
|
ComponentViewModel? GetElement(ComponentSearchModel model);
|
||||||
|
ComponentViewModel? Insert(ComponentBindingModel model);
|
||||||
|
ComponentViewModel? Update(ComponentBindingModel model);
|
||||||
|
ComponentViewModel? Delete(ComponentBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -4,11 +4,11 @@ using FoodOrdersContracts.ViewModels;
|
|||||||
|
|
||||||
namespace FoodOrdersContracts.StoragesContracts
|
namespace FoodOrdersContracts.StoragesContracts
|
||||||
{
|
{
|
||||||
public interface IDishestorage
|
public interface IDishStorage
|
||||||
{
|
{
|
||||||
List<DishViewModel> GetFullList();
|
List<DishViewModel> GetFullList();
|
||||||
List<DishViewModel> GetFilteredList(DishesearchModel model);
|
List<DishViewModel> GetFilteredList(DishSearchModel model);
|
||||||
DishViewModel? GetElement(DishesearchModel model);
|
DishViewModel? GetElement(DishSearchModel model);
|
||||||
DishViewModel? Insert(DishBindingModel model);
|
DishViewModel? Insert(DishBindingModel model);
|
||||||
DishViewModel? Update(DishBindingModel model);
|
DishViewModel? Update(DishBindingModel model);
|
||||||
DishViewModel? Delete(DishBindingModel model);
|
DishViewModel? Delete(DishBindingModel model);
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface ISetOfDishestorage
|
|
||||||
{
|
|
||||||
List<SetOfDishesViewModel> GetFullList();
|
|
||||||
List<SetOfDishesViewModel> GetFilteredList(SetOfDishesearchModel model);
|
|
||||||
SetOfDishesViewModel? GetElement(SetOfDishesearchModel model);
|
|
||||||
SetOfDishesViewModel? Insert(SetOfDishesBindingModel model);
|
|
||||||
SetOfDishesViewModel? Update(SetOfDishesBindingModel model);
|
|
||||||
SetOfDishesViewModel? Delete(SetOfDishesBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,13 @@
|
|||||||
|
using FoodOrdersDataModels.Models;
|
||||||
|
using System.ComponentModel;
|
||||||
|
namespace FoodOrdersContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ComponentViewModel : IComponentModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Название компонента")]
|
||||||
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Цена")]
|
||||||
|
public double Cost { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,15 @@
|
|||||||
using FoodOrdersDataModels.Models;
|
using FoodOrdersDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace FoodOrdersContracts.ViewModels
|
namespace FoodOrdersContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class DishViewModel : IDishModel
|
public class DishViewModel : IDishModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название компонента")]
|
[DisplayName("Название изделия")]
|
||||||
public string DishName { get; set; } = string.Empty;
|
public string DishName { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[DisplayName("Цена")]
|
||||||
public double Cost { get; set; }
|
public double Price { get; set; }
|
||||||
|
public Dictionary<int, (IComponentModel, int)> DishComponents {get; set;} = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,10 @@ namespace FoodOrdersContracts.ViewModels
|
|||||||
[DisplayName("Номер")]
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public int SetOfDishesId { get; set; }
|
public int DishId { get; set; }
|
||||||
|
|
||||||
[DisplayName("Изделие")]
|
[DisplayName("Изделие")]
|
||||||
public string SetOfDishesName { get; set; } = string.Empty;
|
public string DishName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
using FoodOrdersDataModels.Models;
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace FoodOrdersContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class SetOfDishesViewModel : ISetOfDishesModel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
[DisplayName("Название изделия")]
|
|
||||||
public string SetOfDishesName { get; set; } = string.Empty;
|
|
||||||
[DisplayName("Цена")]
|
|
||||||
public double Price { get; set; }
|
|
||||||
public Dictionary<int, (IDishModel, int)> SetOfDishesDishes {get; set;} = new();
|
|
||||||
}
|
|
||||||
}
|
|
9
FoodOrders/FoodOrdersDataModels/IComponentModel.cs
Normal file
9
FoodOrders/FoodOrdersDataModels/IComponentModel.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
namespace FoodOrdersDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IComponentModel : IId
|
||||||
|
{
|
||||||
|
string ComponentName { get; }
|
||||||
|
double Cost { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ namespace FoodOrdersDataModels.Models
|
|||||||
public interface IDishModel : IId
|
public interface IDishModel : IId
|
||||||
{
|
{
|
||||||
string DishName { get; }
|
string DishName { get; }
|
||||||
double Cost { get; }
|
double Price { get; }
|
||||||
|
Dictionary<int, (IComponentModel, int)> DishComponents { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ namespace FoodOrdersDataModels.Models
|
|||||||
{
|
{
|
||||||
public interface IOrderModel : IId
|
public interface IOrderModel : IId
|
||||||
{
|
{
|
||||||
int SetOfDishesId { get; }
|
int DishId { get; }
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
double Sum { get; }
|
double Sum { get; }
|
||||||
OrderStatus Status { get; }
|
OrderStatus Status { get; }
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
namespace FoodOrdersDataModels.Models
|
|
||||||
{
|
|
||||||
public interface ISetOfDishesModel : IId
|
|
||||||
{
|
|
||||||
string SetOfDishesName { get; }
|
|
||||||
double Price { get; }
|
|
||||||
Dictionary<int, (IDishModel, int)> SetOfDishesDishes { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,14 +5,14 @@ namespace FoodOrdersListImplement
|
|||||||
public class DataListSingleton
|
public class DataListSingleton
|
||||||
{
|
{
|
||||||
private static DataListSingleton? _instance;
|
private static DataListSingleton? _instance;
|
||||||
public List<Dish> Dishes { get; set; }
|
public List<Component> Components { get; set; }
|
||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
public List<SetOfDishes> SetOfDishes { get; set; }
|
public List<Dish> Dish { get; set; }
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
Dishes = new List<Dish>();
|
Components = new List<Component>();
|
||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
SetOfDishes = new List<SetOfDishes>();
|
Dish = new List<Dish>();
|
||||||
}
|
}
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,103 @@
|
|||||||
|
using FoodOrdersListImplement.Models;
|
||||||
|
using FoodOrdersContracts.BindingModels;
|
||||||
|
using FoodOrdersContracts.SearchModels;
|
||||||
|
using FoodOrdersContracts.StoragesContracts;
|
||||||
|
using FoodOrdersContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace FoodOrdersListImplement.Implements
|
||||||
|
{
|
||||||
|
public class ComponentStorage : IComponentStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
public ComponentStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
public List<ComponentViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var result = new List<ComponentViewModel>();
|
||||||
|
foreach (var component in _source.Components)
|
||||||
|
{
|
||||||
|
result.Add(component.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel
|
||||||
|
model)
|
||||||
|
{
|
||||||
|
var result = new List<ComponentViewModel>();
|
||||||
|
if (string.IsNullOrEmpty(model.ComponentName))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
foreach (var component in _source.Components)
|
||||||
|
{
|
||||||
|
if (component.ComponentName.Contains(model.ComponentName))
|
||||||
|
{
|
||||||
|
result.Add(component.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public ComponentViewModel? GetElement(ComponentSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var component in _source.Components)
|
||||||
|
{
|
||||||
|
if ((!string.IsNullOrEmpty(model.ComponentName) &&
|
||||||
|
component.ComponentName == model.ComponentName) ||
|
||||||
|
(model.Id.HasValue && component.Id == model.Id))
|
||||||
|
{
|
||||||
|
return component.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public ComponentViewModel? Insert(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = 1;
|
||||||
|
foreach (var component in _source.Components)
|
||||||
|
{
|
||||||
|
if (model.Id <= component.Id)
|
||||||
|
{
|
||||||
|
model.Id = component.Id + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var newComponent = Component.Create(model);
|
||||||
|
if (newComponent == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.Components.Add(newComponent);
|
||||||
|
return newComponent.GetViewModel;
|
||||||
|
}
|
||||||
|
public ComponentViewModel? Update(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
foreach (var component in _source.Components)
|
||||||
|
{
|
||||||
|
if (component.Id == model.Id)
|
||||||
|
{
|
||||||
|
component.Update(model);
|
||||||
|
return component.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public ComponentViewModel? Delete(ComponentBindingModel model)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _source.Components.Count; ++i)
|
||||||
|
{
|
||||||
|
if (_source.Components[i].Id == model.Id)
|
||||||
|
{
|
||||||
|
var element = _source.Components[i];
|
||||||
|
_source.Components.RemoveAt(i);
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,23 +6,23 @@ using FoodOrdersContracts.ViewModels;
|
|||||||
|
|
||||||
namespace FoodOrdersListImplement.Implements
|
namespace FoodOrdersListImplement.Implements
|
||||||
{
|
{
|
||||||
public class Dishestorage : IDishestorage
|
public class DishStorage : IDishStorage
|
||||||
{
|
{
|
||||||
private readonly DataListSingleton _source;
|
private readonly DataListSingleton _source;
|
||||||
public Dishestorage()
|
public DishStorage()
|
||||||
{
|
{
|
||||||
_source = DataListSingleton.GetInstance();
|
_source = DataListSingleton.GetInstance();
|
||||||
}
|
}
|
||||||
public List<DishViewModel> GetFullList()
|
public List<DishViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
var result = new List<DishViewModel>();
|
var result = new List<DishViewModel>();
|
||||||
foreach (var dish in _source.Dishes)
|
foreach (var dish in _source.Dish)
|
||||||
{
|
{
|
||||||
result.Add(dish.GetViewModel);
|
result.Add(dish.GetViewModel);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public List<DishViewModel> GetFilteredList(DishesearchModel
|
public List<DishViewModel> GetFilteredList(DishSearchModel
|
||||||
model)
|
model)
|
||||||
{
|
{
|
||||||
var result = new List<DishViewModel>();
|
var result = new List<DishViewModel>();
|
||||||
@ -30,7 +30,7 @@ namespace FoodOrdersListImplement.Implements
|
|||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
foreach (var dish in _source.Dishes)
|
foreach (var dish in _source.Dish)
|
||||||
{
|
{
|
||||||
if (dish.DishName.Contains(model.DishName))
|
if (dish.DishName.Contains(model.DishName))
|
||||||
{
|
{
|
||||||
@ -39,13 +39,13 @@ namespace FoodOrdersListImplement.Implements
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public DishViewModel? GetElement(DishesearchModel model)
|
public DishViewModel? GetElement(DishSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.DishName) && !model.Id.HasValue)
|
if (string.IsNullOrEmpty(model.DishName) && !model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
foreach (var dish in _source.Dishes)
|
foreach (var dish in _source.Dish)
|
||||||
{
|
{
|
||||||
if ((!string.IsNullOrEmpty(model.DishName) &&
|
if ((!string.IsNullOrEmpty(model.DishName) &&
|
||||||
dish.DishName == model.DishName) ||
|
dish.DishName == model.DishName) ||
|
||||||
@ -59,7 +59,7 @@ namespace FoodOrdersListImplement.Implements
|
|||||||
public DishViewModel? Insert(DishBindingModel model)
|
public DishViewModel? Insert(DishBindingModel model)
|
||||||
{
|
{
|
||||||
model.Id = 1;
|
model.Id = 1;
|
||||||
foreach (var dish in _source.Dishes)
|
foreach (var dish in _source.Dish)
|
||||||
{
|
{
|
||||||
if (model.Id <= dish.Id)
|
if (model.Id <= dish.Id)
|
||||||
{
|
{
|
||||||
@ -71,12 +71,12 @@ namespace FoodOrdersListImplement.Implements
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_source.Dishes.Add(newDish);
|
_source.Dish.Add(newDish);
|
||||||
return newDish.GetViewModel;
|
return newDish.GetViewModel;
|
||||||
}
|
}
|
||||||
public DishViewModel? Update(DishBindingModel model)
|
public DishViewModel? Update(DishBindingModel model)
|
||||||
{
|
{
|
||||||
foreach (var dish in _source.Dishes)
|
foreach (var dish in _source.Dish)
|
||||||
{
|
{
|
||||||
if (dish.Id == model.Id)
|
if (dish.Id == model.Id)
|
||||||
{
|
{
|
||||||
@ -88,12 +88,12 @@ namespace FoodOrdersListImplement.Implements
|
|||||||
}
|
}
|
||||||
public DishViewModel? Delete(DishBindingModel model)
|
public DishViewModel? Delete(DishBindingModel model)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _source.Dishes.Count; ++i)
|
for (int i = 0; i < _source.Dish.Count; ++i)
|
||||||
{
|
{
|
||||||
if (_source.Dishes[i].Id == model.Id)
|
if (_source.Dish[i].Id == model.Id)
|
||||||
{
|
{
|
||||||
var element = _source.Dishes[i];
|
var element = _source.Dish[i];
|
||||||
_source.Dishes.RemoveAt(i);
|
_source.Dish.RemoveAt(i);
|
||||||
return element.GetViewModel;
|
return element.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,103 +0,0 @@
|
|||||||
using FoodOrdersListImplement.Models;
|
|
||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.SearchModels;
|
|
||||||
using FoodOrdersContracts.StoragesContracts;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
|
|
||||||
namespace FoodOrdersListImplement.Implements
|
|
||||||
{
|
|
||||||
public class SetOfDishestorage : ISetOfDishestorage
|
|
||||||
{
|
|
||||||
private readonly DataListSingleton _source;
|
|
||||||
public SetOfDishestorage()
|
|
||||||
{
|
|
||||||
_source = DataListSingleton.GetInstance();
|
|
||||||
}
|
|
||||||
public List<SetOfDishesViewModel> GetFullList()
|
|
||||||
{
|
|
||||||
var result = new List<SetOfDishesViewModel>();
|
|
||||||
foreach (var set_of_dishes in _source.SetOfDishes)
|
|
||||||
{
|
|
||||||
result.Add(set_of_dishes.GetViewModel);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public List<SetOfDishesViewModel> GetFilteredList(SetOfDishesearchModel
|
|
||||||
model)
|
|
||||||
{
|
|
||||||
var result = new List<SetOfDishesViewModel>();
|
|
||||||
if (string.IsNullOrEmpty(model.SetOfDishesName))
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
foreach (var set_of_dishes in _source.SetOfDishes)
|
|
||||||
{
|
|
||||||
if (set_of_dishes.SetOfDishesName.Contains(model.SetOfDishesName))
|
|
||||||
{
|
|
||||||
result.Add(set_of_dishes.GetViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public SetOfDishesViewModel? GetElement(SetOfDishesearchModel model)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(model.SetOfDishesName) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var set_of_dishes in _source.SetOfDishes)
|
|
||||||
{
|
|
||||||
if ((!string.IsNullOrEmpty(model.SetOfDishesName) &&
|
|
||||||
set_of_dishes.SetOfDishesName == model.SetOfDishesName) ||
|
|
||||||
(model.Id.HasValue && set_of_dishes.Id == model.Id))
|
|
||||||
{
|
|
||||||
return set_of_dishes.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public SetOfDishesViewModel? Insert(SetOfDishesBindingModel model)
|
|
||||||
{
|
|
||||||
model.Id = 1;
|
|
||||||
foreach (var set_of_dishes in _source.SetOfDishes)
|
|
||||||
{
|
|
||||||
if (model.Id <= set_of_dishes.Id)
|
|
||||||
{
|
|
||||||
model.Id = set_of_dishes.Id + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newSetOfDishes = SetOfDishes.Create(model);
|
|
||||||
if (newSetOfDishes == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_source.SetOfDishes.Add(newSetOfDishes);
|
|
||||||
return newSetOfDishes.GetViewModel;
|
|
||||||
}
|
|
||||||
public SetOfDishesViewModel? Update(SetOfDishesBindingModel model)
|
|
||||||
{
|
|
||||||
foreach (var set_of_dishes in _source.SetOfDishes)
|
|
||||||
{
|
|
||||||
if (set_of_dishes.Id == model.Id)
|
|
||||||
{
|
|
||||||
set_of_dishes.Update(model);
|
|
||||||
return set_of_dishes.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public SetOfDishesViewModel? Delete(SetOfDishesBindingModel model)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _source.SetOfDishes.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_source.SetOfDishes[i].Id == model.Id)
|
|
||||||
{
|
|
||||||
var element = _source.SetOfDishes[i];
|
|
||||||
_source.SetOfDishes.RemoveAt(i);
|
|
||||||
return element.GetViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
41
FoodOrders/FoodOrdersListImplement/Models/Component.cs
Normal file
41
FoodOrders/FoodOrdersListImplement/Models/Component.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using FoodOrdersContracts.BindingModels;
|
||||||
|
using FoodOrdersContracts.ViewModels;
|
||||||
|
using FoodOrdersDataModels.Models;
|
||||||
|
|
||||||
|
namespace FoodOrdersListImplement.Models
|
||||||
|
{
|
||||||
|
public class Component : IComponentModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
public string ComponentName { get; private set; } = string.Empty;
|
||||||
|
public double Cost { get; set; }
|
||||||
|
public static Component? Create(ComponentBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Component()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ComponentName = model.ComponentName,
|
||||||
|
Cost = model.Cost
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ComponentBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ComponentName = model.ComponentName;
|
||||||
|
Cost = model.Cost;
|
||||||
|
}
|
||||||
|
public ComponentViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ComponentName = ComponentName,
|
||||||
|
Cost = Cost
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,12 @@ namespace FoodOrdersListImplement.Models
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public string DishName { get; private set; } = string.Empty;
|
public string DishName { get; private set; } = string.Empty;
|
||||||
public double Cost { get; set; }
|
public double Price { get; private set; }
|
||||||
|
public Dictionary<int, (IComponentModel, int)> DishComponents
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
} = new Dictionary<int, (IComponentModel, int)>();
|
||||||
public static Dish? Create(DishBindingModel? model)
|
public static Dish? Create(DishBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -19,7 +24,8 @@ namespace FoodOrdersListImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
DishName = model.DishName,
|
DishName = model.DishName,
|
||||||
Cost = model.Cost
|
Price = model.Price,
|
||||||
|
DishComponents = model.DishComponents
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(DishBindingModel? model)
|
public void Update(DishBindingModel? model)
|
||||||
@ -29,13 +35,15 @@ namespace FoodOrdersListImplement.Models
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DishName = model.DishName;
|
DishName = model.DishName;
|
||||||
Cost = model.Cost;
|
Price = model.Price;
|
||||||
|
DishComponents = model.DishComponents;
|
||||||
}
|
}
|
||||||
public DishViewModel GetViewModel => new()
|
public DishViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
DishName = DishName,
|
DishName = DishName,
|
||||||
Cost = Cost
|
Price = Price,
|
||||||
|
DishComponents = DishComponents
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,8 +9,8 @@ namespace FoodOrdersListImplement.Models
|
|||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public int SetOfDishesId { get; private set; }
|
public int DishId { get; private set; }
|
||||||
public string SetOfDishesName { get; private set; } = string.Empty;
|
public string DishName { 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; }
|
||||||
public OrderStatus Status { get; private set; }
|
public OrderStatus Status { get; private set; }
|
||||||
@ -26,8 +26,8 @@ namespace FoodOrdersListImplement.Models
|
|||||||
return new Order()
|
return new Order()
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
SetOfDishesId = model.SetOfDishesId,
|
DishId = model.DishId,
|
||||||
SetOfDishesName = model.SetOfDishesName,
|
DishName = model.DishName,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
@ -41,8 +41,8 @@ namespace FoodOrdersListImplement.Models
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SetOfDishesId = model.SetOfDishesId;
|
DishId = model.DishId;
|
||||||
SetOfDishesName = model.SetOfDishesName;
|
DishName = model.DishName;
|
||||||
Count = model.Count;
|
Count = model.Count;
|
||||||
Sum = model.Sum;
|
Sum = model.Sum;
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
@ -52,8 +52,8 @@ namespace FoodOrdersListImplement.Models
|
|||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
SetOfDishesId = SetOfDishesId,
|
DishId = DishId,
|
||||||
SetOfDishesName = SetOfDishesName,
|
DishName = DishName,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
|
||||||
using FoodOrdersContracts.ViewModels;
|
|
||||||
using FoodOrdersDataModels.Models;
|
|
||||||
|
|
||||||
namespace FoodOrdersListImplement.Models
|
|
||||||
{
|
|
||||||
public class SetOfDishes : ISetOfDishesModel
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string SetOfDishesName { get; private set; } = string.Empty;
|
|
||||||
public double Price { get; private set; }
|
|
||||||
public Dictionary<int, (IDishModel, int)> SetOfDishesDishes
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
private set;
|
|
||||||
} = new Dictionary<int, (IDishModel, int)>();
|
|
||||||
public static SetOfDishes? Create(SetOfDishesBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new SetOfDishes()
|
|
||||||
{
|
|
||||||
Id = model.Id,
|
|
||||||
SetOfDishesName = model.SetOfDishesName,
|
|
||||||
Price = model.Price,
|
|
||||||
SetOfDishesDishes = model.SetOfDishesDishes
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public void Update(SetOfDishesBindingModel? model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SetOfDishesName = model.SetOfDishesName;
|
|
||||||
Price = model.Price;
|
|
||||||
SetOfDishesDishes = model.SetOfDishesDishes;
|
|
||||||
}
|
|
||||||
public SetOfDishesViewModel GetViewModel => new()
|
|
||||||
{
|
|
||||||
Id = Id,
|
|
||||||
SetOfDishesName = SetOfDishesName,
|
|
||||||
Price = Price,
|
|
||||||
SetOfDishesDishes = SetOfDishesDishes
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user