Доделал многие-ко-многим Машина Комплектация
This commit is contained in:
parent
fb65ccd9a2
commit
8a4a34b232
@ -29,5 +29,6 @@ namespace CarCenterDatabaseImplement
|
||||
public virtual DbSet<Request> Requests { set; get; }
|
||||
public virtual DbSet<Feature> Features { set; get; }
|
||||
public virtual DbSet<Bundling> Bundlings { set; get; }
|
||||
public virtual DbSet<CarBundling> CarBundlings { set; get; }
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,22 @@ namespace CarCenterDatabaseImplement.Models
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public void UpdateBundlings(CarCenterDatabase context, CarBindingModel model)
|
||||
{
|
||||
var car = context.Cars.First(x => x.Id == Id);
|
||||
foreach (var pc in model.CarBundlings)
|
||||
{
|
||||
context.CarBundlings.Add(new CarBundling
|
||||
{
|
||||
Car = car,
|
||||
Bundling = context.Bundlings.First(x => x.Id == pc.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_carBundlings = null;
|
||||
}
|
||||
|
||||
public void Update(CarBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
@ -104,6 +120,7 @@ namespace CarCenterDatabaseImplement.Models
|
||||
Price = Price,
|
||||
VINnumber = VINnumber,
|
||||
FeatureID = FeatureID,
|
||||
CarBundlings = CarBundlings,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user