Zacharchenko Lab work 3 Hard #8
@ -12,8 +12,8 @@ using PizzeriaDatabaseImplement;
|
||||
namespace PizzeriaDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(PizzeriaDatabase))]
|
||||
[Migration("20230309000843_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
[Migration("20230308222141_InitMigration")]
|
||||
partial class InitMigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
namespace PizzeriaDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
public partial class InitMigration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
@ -63,11 +63,9 @@ namespace PizzeriaDatabaseImplement.Models
|
||||
{
|
||||
var pizzaComponents = context.PizzaComponents.Where(rec => rec.ProductId == model.Id).ToList();
|
||||
|
||||
if (pizzaComponents != null && pizzaComponents.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
if (pizzaComponents != null && pizzaComponents.Count > 0) {
|
||||
context.PizzaComponents.RemoveRange(pizzaComponents.Where(rec => !model.PizzaComponents.ContainsKey(rec.ComponentId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateComponent in pizzaComponents)
|
||||
{
|
||||
updateComponent.Count = model.PizzaComponents[updateComponent.ComponentId].Item2;
|
||||
|
@ -10,7 +10,7 @@ namespace PizzeriaDatabaseImplement
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Server=shadowik;Initial Catalog=PizzeriaDatabase;Integrated Security=True;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=SHADOWIK\SHADOWIK;Initial Catalog=PizzeriaDatabase;Integrated Security=True;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -20,8 +20,4 @@
|
||||
<ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user