Новый коммит

This commit is contained in:
dimazhelovanov 2023-03-01 18:19:09 +03:00
parent 2f48aa61ed
commit 3b650532c4
6 changed files with 29 additions and 4 deletions

View File

@ -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)
{

View File

@ -24,6 +24,7 @@ logic)
InitializeComponent();
_logger = logger;
_logic = logic;
LoadData();
}
private void FormComponents_Load(object sender, EventArgs e)
{

View File

@ -24,6 +24,7 @@ namespace BlacksmithWorkshop
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
LoadData();
}

View File

@ -22,6 +22,7 @@ namespace BlacksmithWorkshop
InitializeComponent();
_logger = logger;
_logic = logic;
LoadData();
}
private void LoadData()
{

View File

@ -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;

View File

@ -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;
}
}
}