Guarator: Db's variables' name fixes.

This commit is contained in:
Yuee Shiness 2023-04-07 21:49:30 +04:00
parent fbf7292ee2
commit 262e730c94
2 changed files with 4 additions and 4 deletions

View File

@ -24,6 +24,6 @@ namespace ComputerStoreDatabaseImplement
public virtual DbSet<PC> PCs { get; set; }
public virtual DbSet<Employee> Employees { get; set; }
public virtual DbSet<RequestComponent> RequestComponents { get; set; }
public virtual DbSet<ProductComponent> ConsignmentComponents { get; set; }
public virtual DbSet<ProductComponent> ProductComponents { get; set; }
}
}

View File

@ -82,10 +82,10 @@ namespace ComputerStoreDatabaseImplement.Models
public void UpdateComponents(ComputerStoreDatabase context, ProductBindingModel model)
{
var productComponents = context.ConsignmentComponents.Where(rec => rec.ProductID == model.ID).ToList();
var productComponents = context.ProductComponents.Where(rec => rec.ProductID == model.ID).ToList();
if(productComponents != null && productComponents.Count > 0)
{
context.ConsignmentComponents.RemoveRange(productComponents.Where(rec => !model.ProductComponents.ContainsKey(rec.ComponentID)));
context.ProductComponents.RemoveRange(productComponents.Where(rec => !model.ProductComponents.ContainsKey(rec.ComponentID)));
context.SaveChanges();
foreach(var updateComponent in productComponents)
{
@ -98,7 +98,7 @@ namespace ComputerStoreDatabaseImplement.Models
var product = context.Products.First(x => x.ID == ID);
foreach(var pc in model.ProductComponents)
{
context.ConsignmentComponents.Add(new ProductComponent
context.ProductComponents.Add(new ProductComponent
{
Product = product,
Component = context.Components.First(x => x.ID == pc.Key),