diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.cs index c742080..8e82fa8 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponent.cs @@ -1,6 +1,7 @@ using BlacksmithWorkshopContracts.BindingModels; using BlacksmithWorkshopContracts.BusinessLogicsContracts; using BlacksmithWorkshopContracts.SearchModels; +using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -27,6 +28,7 @@ logic) InitializeComponent(); _logger = logger; _logic = logic; + } private void FormComponent_Load(object sender, EventArgs e) { diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs index 31135b3..ae4a014 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs @@ -24,6 +24,7 @@ logic) InitializeComponent(); _logger = logger; _logic = logic; + LoadData(); } private void FormComponents_Load(object sender, EventArgs e) { diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs index c20301f..5665d5a 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -24,6 +24,7 @@ namespace BlacksmithWorkshop InitializeComponent(); _logger = logger; _orderLogic = orderLogic; + LoadData(); } diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs index 9fa95a1..fc03d6f 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs @@ -22,6 +22,7 @@ namespace BlacksmithWorkshop InitializeComponent(); _logger = logger; _logic = logic; + LoadData(); } private void LoadData() { diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs index f7872f4..c641ef7 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs @@ -1,7 +1,7 @@ using BlacksmithWorkshopBusinessLogic.BusinessLogics; using BlacksmithWorkshopContracts.BusinessLogicsContracts; using BlacksmithWorkshopContracts.StoragesContracts; -using BlacksmithWorkshopFileImplement.Implements; +using BlacksmithWorkshopDatabaseImplement.Implements; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs index 400d08a..e9b864f 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace BlacksmithWorkshopDatabaseImplement.Implements { - internal class OrderStorage : IOrderStorage + public class OrderStorage : IOrderStorage { public OrderViewModel? Delete(OrderBindingModel model) { @@ -66,12 +66,32 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements public OrderViewModel? Insert(OrderBindingModel model) { - throw new NotImplementedException(); + using var context = new BlacksmithWorkshopDatabase(); + var newProduct = Order.Create(model); + if (newProduct == null) + { + return null; + } + context.Orders.Add(newProduct); + context.SaveChanges(); + return newProduct.GetViewModel; } public OrderViewModel? Update(OrderBindingModel model) { - throw new NotImplementedException(); + using var context = new BlacksmithWorkshopDatabase(); + + var product = context.Orders.FirstOrDefault(rec => + rec.Id == model.Id); + if (product == null) + { + return null; + } + product.Update(model); + context.SaveChanges(); + + return product.GetViewModel; + } } }