From deef66e3fc32d68dc01461d690395369a2ebd72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D0=B8=D0=BD=D0=B0=20=D0=A7=D1=83=D0=B1?= =?UTF-8?q?=D1=8B=D0=BA=D0=B8=D0=BD=D0=B0?= Date: Wed, 28 Feb 2024 10:03:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BB=D0=B0=D0=B1=D0=B0=201=20=D0=B3=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D0=B2=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConfectioneryBusinessLogic/OrderLogic.cs | 4 +- .../ConfectioneryBusinessLogic/PastryLogic.cs | 8 +-- .../ConfectioneryListImplement/Order.cs | 43 ++++++++++++---- .../FormCreateOrder.Designer.cs | 1 + .../ConfectioneryView/FormPastry.Designer.cs | 51 ++++++++++--------- 5 files changed, 67 insertions(+), 40 deletions(-) diff --git a/Confectionery/ConfectioneryBusinessLogic/OrderLogic.cs b/Confectionery/ConfectioneryBusinessLogic/OrderLogic.cs index 939b321..a9f668d 100644 --- a/Confectionery/ConfectioneryBusinessLogic/OrderLogic.cs +++ b/Confectionery/ConfectioneryBusinessLogic/OrderLogic.cs @@ -82,11 +82,11 @@ namespace ConfectioneryBusinessLogic.BusinessLogics } if (model.PastryId <= 0) { - throw new ArgumentNullException("Некорректный идентификатор мороженого", nameof(model.PastryId)); + throw new ArgumentNullException("Некорректный идентификатор выпечки", nameof(model.PastryId)); } if (model.Count <= 0) { - throw new ArgumentNullException("В заказе должно быть хотя бы одно мороженое", nameof(model.Count)); + throw new ArgumentNullException("В заказе должно быть хотя бы одна выпечка", nameof(model.Count)); } if (model.Sum <= 0) { diff --git a/Confectionery/ConfectioneryBusinessLogic/PastryLogic.cs b/Confectionery/ConfectioneryBusinessLogic/PastryLogic.cs index 549c7bd..e356da6 100644 --- a/Confectionery/ConfectioneryBusinessLogic/PastryLogic.cs +++ b/Confectionery/ConfectioneryBusinessLogic/PastryLogic.cs @@ -100,15 +100,15 @@ namespace ConfectioneryBusinessLogic.BusinessLogics } if (string.IsNullOrEmpty(model.PastryName)) { - throw new ArgumentNullException("Нет названия мороженого", nameof(model.PastryName)); + throw new ArgumentNullException("Нет названия выпечки", nameof(model.PastryName)); } if (model.Price <= 0) { - throw new ArgumentNullException("Цена мороженого должна быть больше 0", nameof(model.Price)); + throw new ArgumentNullException("Цена выпечки должна быть больше 0", nameof(model.Price)); } if (model.PastryComponents == null || model.PastryComponents.Count == 0) { - throw new ArgumentNullException("Мороженое должно состоять хотя бы из одного компонента"); + throw new ArgumentNullException("Выпечка должна состоять хотя бы из одного компонента"); } _logger.LogInformation("Pastry. PastryName: {PastryName}. Price: {Price}. Id: {Id}", model.PastryName, model.Price, model.Id); var element = _pastryStorage.GetElement(new PastrySearchModel @@ -117,7 +117,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics }); if (element != null && element.Id != model.Id) { - throw new InvalidOperationException("Мороженое с таким названием уже есть"); + throw new InvalidOperationException("Выпечка с таким названием уже есть"); } } } diff --git a/Confectionery/ConfectioneryListImplement/Order.cs b/Confectionery/ConfectioneryListImplement/Order.cs index b35f396..7f0cb44 100644 --- a/Confectionery/ConfectioneryListImplement/Order.cs +++ b/Confectionery/ConfectioneryListImplement/Order.cs @@ -12,32 +12,57 @@ namespace ConfectioneryListImplement { internal class Order : IOrderModel { - public int PastryId => throw new NotImplementedException(); + public int Id { get; private set; } - public int Count => throw new NotImplementedException(); + public int PastryId { get; private set; } - public double Sum => throw new NotImplementedException(); + public int Count { get; private set; } - public OrderStatus Status => throw new NotImplementedException(); + public double Sum { get; private set; } - public DateTime DateCreate => throw new NotImplementedException(); + public OrderStatus Status { get; private set; } - public DateTime? DateImplement => throw new NotImplementedException(); + public DateTime DateCreate { get; private set; } - public int Id => throw new NotImplementedException(); + public DateTime? DateImplement { get; private set; } public static Order? Create(OrderBindingModel? model) { - return new Order(); + if (model == null) + { + return null; + } + return new Order() + { + Id = model.Id, + PastryId = model.PastryId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement + }; } public void Update(OrderBindingModel? model) { - + if (model == null) + { + return; + } + Status = model.Status; + DateImplement = model.DateImplement; } public OrderViewModel GetViewModel => new() { + Id = Id, + PastryId = PastryId, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement }; } } diff --git a/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs b/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs index 1e7a083..5ecf40e 100644 --- a/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs +++ b/Confectionery/ConfectioneryView/FormCreateOrder.Designer.cs @@ -84,6 +84,7 @@ // // textBoxSum // + this.textBoxSum.Enabled = false; this.textBoxSum.Location = new System.Drawing.Point(150, 95); this.textBoxSum.Name = "textBoxSum"; this.textBoxSum.Size = new System.Drawing.Size(429, 27); diff --git a/Confectionery/ConfectioneryView/FormPastry.Designer.cs b/Confectionery/ConfectioneryView/FormPastry.Designer.cs index 13090a7..722b427 100644 --- a/Confectionery/ConfectioneryView/FormPastry.Designer.cs +++ b/Confectionery/ConfectioneryView/FormPastry.Designer.cs @@ -31,6 +31,9 @@ this.textBoxName = new System.Windows.Forms.TextBox(); this.textBoxPrice = new System.Windows.Forms.TextBox(); this.dataGridView = new System.Windows.Forms.DataGridView(); + this.Number = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.groupBox = new System.Windows.Forms.GroupBox(); this.ButtonRef = new System.Windows.Forms.Button(); this.ButtonDel = new System.Windows.Forms.Button(); @@ -40,9 +43,6 @@ this.ButtonCancel = new System.Windows.Forms.Button(); this.labelName = new System.Windows.Forms.Label(); this.labelPrice = new System.Windows.Forms.Label(); - this.Number = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.groupBox.SuspendLayout(); this.SuspendLayout(); @@ -56,6 +56,7 @@ // // textBoxPrice // + this.textBoxPrice.Enabled = false; this.textBoxPrice.Location = new System.Drawing.Point(204, 64); this.textBoxPrice.Name = "textBoxPrice"; this.textBoxPrice.Size = new System.Drawing.Size(125, 27); @@ -75,6 +76,28 @@ this.dataGridView.Size = new System.Drawing.Size(422, 297); this.dataGridView.TabIndex = 2; // + // Number + // + this.Number.HeaderText = "Номер"; + this.Number.MinimumWidth = 6; + this.Number.Name = "Number"; + this.Number.Visible = false; + this.Number.Width = 125; + // + // Component + // + this.Component.HeaderText = "Компонент"; + this.Component.MinimumWidth = 6; + this.Component.Name = "Component"; + this.Component.Width = 125; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.MinimumWidth = 6; + this.Count.Name = "Count"; + this.Count.Width = 125; + // // groupBox // this.groupBox.Controls.Add(this.ButtonRef); @@ -167,28 +190,6 @@ this.labelPrice.TabIndex = 10; this.labelPrice.Text = "Стоимость:"; // - // Number - // - this.Number.HeaderText = "Номер"; - this.Number.MinimumWidth = 6; - this.Number.Name = "Number"; - this.Number.Visible = false; - this.Number.Width = 125; - // - // Component - // - this.Component.HeaderText = "Компонент"; - this.Component.MinimumWidth = 6; - this.Component.Name = "Component"; - this.Component.Width = 125; - // - // Count - // - this.Count.HeaderText = "Количество"; - this.Count.MinimumWidth = 6; - this.Count.Name = "Count"; - this.Count.Width = 125; - // // FormPastry // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);