Guarator: Db's variables' name fixes.
This commit is contained in:
parent
fbf7292ee2
commit
262e730c94
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user