BeforeChangeToList
Люди бесятся с водки, люди бесятся с жиру Люди думают вечно одно Люди тычут в спину, их пальцы горят А в ботинки стекает дерьмо
This commit is contained in:
parent
f502a218a7
commit
6da52a2500
@ -62,6 +62,10 @@ namespace BusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Cost));
|
throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Cost));
|
||||||
}
|
}
|
||||||
|
if (model.ProductDetails.Count == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Количество деталей в изделии должно быть больше 0", nameof(model.ProductDetails));
|
||||||
|
}
|
||||||
_logger.LogInformation("Product. ProductName:{Name}. Cost:{Cost}. Id:{Id}", model.Name, model.Cost, model.Id);
|
_logger.LogInformation("Product. ProductName:{Name}. Cost:{Cost}. Id:{Id}", model.Name, model.Cost, model.Id);
|
||||||
var elem = _productStorage.GetElement(new ProductSearchModel
|
var elem = _productStorage.GetElement(new ProductSearchModel
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ namespace Contracts.BindingModels
|
|||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
public Dictionary<int, (IDetailModel, int)> ProductionDetails { get; set; } = new();
|
public Dictionary<int, IDetailModel> ProductionDetails { get; set; } = new();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
|
|
||||||
namespace DatabaseImplement.Implements
|
namespace DatabaseImplement.Implements
|
||||||
{
|
{
|
||||||
public class ProductionionStorage : IProductionStorage
|
public class ProductionStorage : IProductionStorage
|
||||||
{
|
{
|
||||||
public ProductionViewModel? Delete(ProductionBindingModel model)
|
public ProductionViewModel? Delete(ProductionBindingModel model)
|
||||||
{
|
{
|
||||||
@ -15,6 +15,7 @@ namespace DatabaseImplement.Implements
|
|||||||
var newProduction = context.Productions.FirstOrDefault(x => x.Id == model.Id);
|
var newProduction = context.Productions.FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (newProduction == null)
|
if (newProduction == null)
|
||||||
return null;
|
return null;
|
||||||
|
newProduction.UpdateDetails(context, model);
|
||||||
context.Productions.Remove(newProduction);
|
context.Productions.Remove(newProduction);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return newProduction.GetViewModel;
|
return newProduction.GetViewModel;
|
||||||
@ -60,6 +61,7 @@ namespace DatabaseImplement.Implements
|
|||||||
if (newProduction == null)
|
if (newProduction == null)
|
||||||
return null;
|
return null;
|
||||||
newProduction.Update(model);
|
newProduction.Update(model);
|
||||||
|
newProduction.UpdateDetails(context, model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return newProduction.GetViewModel;
|
return newProduction.GetViewModel;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ namespace DatabaseImplement.Models
|
|||||||
var productionDetails = context.DetailProductions.Where(rec => rec.ProductionId == model.Id).ToList();
|
var productionDetails = context.DetailProductions.Where(rec => rec.ProductionId == model.Id).ToList();
|
||||||
if (productionDetails != null && productionDetails.Count > 0)
|
if (productionDetails != null && productionDetails.Count > 0)
|
||||||
{
|
{
|
||||||
context.DetailProductions.RemoveRange(productionDetails.Where(rec => !model.ProductionDetails.ContainsKey(rec.DetailId)));
|
context.DetailProductions.RemoveRange(productionDetails.Where(rec => model.ProductionDetails.ContainsKey(rec.ProductionId)));
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
var production = context.Productions.First(x => x.Id == model.Id);
|
var production = context.Productions.First(x => x.Id == model.Id);
|
||||||
|
@ -10,8 +10,16 @@ using DataModels.Models;
|
|||||||
|
|
||||||
DetailStorage detailStorage = new DetailStorage();
|
DetailStorage detailStorage = new DetailStorage();
|
||||||
ImplementerStorage implementationStorage = new ImplementerStorage();
|
ImplementerStorage implementationStorage = new ImplementerStorage();
|
||||||
ProductionionStorage productionionStorage = new ProductionionStorage();
|
ProductionStorage productionionStorage = new ProductionStorage();
|
||||||
ProductStorage productStorage = new ProductStorage();
|
ProductStorage productStorage = new ProductStorage();
|
||||||
|
|
||||||
var i = productStorage.GetFullList();
|
productionionStorage.Insert(new()
|
||||||
Console.WriteLine(i);
|
{
|
||||||
|
UserId = 1,
|
||||||
|
Name = "Test",
|
||||||
|
Cost = 1,
|
||||||
|
ProductionDetails = new()
|
||||||
|
{
|
||||||
|
{2, detailStorage.GetElement(new() { Id = 2,}) }, {3, detailStorage.GetElement(new() {Id = 3})}
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user