This commit is contained in:
Данияр Аглиуллов 2023-02-18 16:14:11 +04:00
parent a803558b09
commit 77889d887e
4 changed files with 8 additions and 11 deletions

View File

@ -63,14 +63,14 @@ namespace ConfectioneryFileImplement
public OrderViewModel? Update(OrderBindingModel model) public OrderViewModel? Update(OrderBindingModel model)
{ {
var pastry = _source.Orders.FirstOrDefault(x => x.Id == model.Id); var order = _source.Orders.FirstOrDefault(x => x.Id == model.Id);
if (pastry == null) if (order == null)
{ {
return null; return null;
} }
pastry.Update(model); order.Update(model);
_source.SaveOrders(); _source.SaveOrders();
return pastry.GetViewModel; return order.GetViewModel;
} }
} }
} }

View File

@ -1,7 +1,6 @@
using ConfectioneryContracts.BindingModels; using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.ViewModels; using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Models; using ConfectioneryDataModels.Models;
using ConfectioneryDataModels.Models;
using System.Xml.Linq; using System.Xml.Linq;
namespace ConfectioneryFileImplement.Models namespace ConfectioneryFileImplement.Models

View File

@ -103,7 +103,7 @@
this.textBoxCount.Name = "textBoxCount"; this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(214, 23); this.textBoxCount.Size = new System.Drawing.Size(214, 23);
this.textBoxCount.TabIndex = 6; this.textBoxCount.TabIndex = 6;
this.textBoxCount.Click += new System.EventHandler(this.TextBoxCount_TextChanged); this.textBoxCount.ValueChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
// //
// textBoxSum // textBoxSum
// //

View File

@ -39,8 +39,7 @@ namespace ConfectioneryView
} }
private void CalcSum() private void CalcSum()
{ {
if (comboBoxPastry.SelectedValue != null && if (comboBoxPastry.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
!string.IsNullOrEmpty(textBoxCount.Text))
{ {
try try
{ {
@ -49,9 +48,8 @@ namespace ConfectioneryView
{ {
Id = id Id = id
}); });
int count = Convert.ToInt32(textBoxCount.Text); int count = Convert.ToInt32(textBoxCount.Value);
textBoxSum.Text = Math.Round(count * (pastry?.Price ?? 0), textBoxSum.Text = Math.Round(count * (pastry?.Price ?? 0), 2).ToString();
2).ToString();
_logger.LogInformation("Расчет суммы заказа"); _logger.LogInformation("Расчет суммы заказа");
} }
catch (Exception ex) catch (Exception ex)