Фальшивого дрессировщика в цирке быстро раскусили.
This commit is contained in:
commit
3cbab2be56
@ -14,7 +14,6 @@ namespace DatabaseImplement.Models
|
|||||||
public int DetailId { get; set; }
|
public int DetailId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public int ProductionId { get; set; }
|
public int ProductionId { get; set; }
|
||||||
|
|
||||||
public virtual Detail Detail { get; set; } = new();
|
public virtual Detail Detail { get; set; } = new();
|
||||||
public virtual Production Production { get; set; } = new();
|
public virtual Production Production { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
@ -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.ProductionId)));
|
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);
|
||||||
|
@ -14,3 +14,17 @@ ProductionStorage productionionStorage = new ProductionStorage();
|
|||||||
ProductStorage productStorage = new ProductStorage();
|
ProductStorage productStorage = new ProductStorage();
|
||||||
MachineStorage machineStorage = new MachineStorage();
|
MachineStorage machineStorage = new MachineStorage();
|
||||||
GuarantorStorage guarantorStorage = new GuarantorStorage();
|
GuarantorStorage guarantorStorage = new GuarantorStorage();
|
||||||
|
|
||||||
|
|
||||||
|
productionionStorage.Update(new()
|
||||||
|
{
|
||||||
|
Id = 4,
|
||||||
|
Name = "name",
|
||||||
|
Cost = 1,
|
||||||
|
UserId = 1,
|
||||||
|
ProductionDetails = new()
|
||||||
|
{
|
||||||
|
{1, detailStorage.GetElement(new() { Id = 1 }) },
|
||||||
|
{3, detailStorage.GetElement(new() { Id = 3 }) }
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user