From 8cde12c752d9077f71ac253330f0080116153d3e Mon Sep 17 00:00:00 2001 From: shadowik Date: Thu, 9 Mar 2023 07:30:15 +0300 Subject: [PATCH] Final --- ...e.Designer.cs => 20230308222141_InitMigration.Designer.cs} | 4 ++-- ...00843_InitialCreate.cs => 20230308222141_InitMigration.cs} | 2 +- Pizzeria/PizzeriaDatabaseImplement/Models/Pizza.cs | 4 +--- Pizzeria/PizzeriaDatabaseImplement/PizzeriaDatabase.cs | 2 +- .../PizzeriaDatabaseImplement.csproj | 4 ---- 5 files changed, 5 insertions(+), 11 deletions(-) rename Pizzeria/PizzeriaDatabaseImplement/Migrations/{20230309000843_InitialCreate.Designer.cs => 20230308222141_InitMigration.Designer.cs} (98%) rename Pizzeria/PizzeriaDatabaseImplement/Migrations/{20230309000843_InitialCreate.cs => 20230308222141_InitMigration.cs} (99%) diff --git a/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230309000843_InitialCreate.Designer.cs b/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230308222141_InitMigration.Designer.cs similarity index 98% rename from Pizzeria/PizzeriaDatabaseImplement/Migrations/20230309000843_InitialCreate.Designer.cs rename to Pizzeria/PizzeriaDatabaseImplement/Migrations/20230308222141_InitMigration.Designer.cs index fbe12a8..05251d8 100644 --- a/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230309000843_InitialCreate.Designer.cs +++ b/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230308222141_InitMigration.Designer.cs @@ -12,8 +12,8 @@ using PizzeriaDatabaseImplement; namespace PizzeriaDatabaseImplement.Migrations { [DbContext(typeof(PizzeriaDatabase))] - [Migration("20230309000843_InitialCreate")] - partial class InitialCreate + [Migration("20230308222141_InitMigration")] + partial class InitMigration { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230309000843_InitialCreate.cs b/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230308222141_InitMigration.cs similarity index 99% rename from Pizzeria/PizzeriaDatabaseImplement/Migrations/20230309000843_InitialCreate.cs rename to Pizzeria/PizzeriaDatabaseImplement/Migrations/20230308222141_InitMigration.cs index ef650ef..27c2c27 100644 --- a/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230309000843_InitialCreate.cs +++ b/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230308222141_InitMigration.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace PizzeriaDatabaseImplement.Migrations { /// - public partial class InitialCreate : Migration + public partial class InitMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) diff --git a/Pizzeria/PizzeriaDatabaseImplement/Models/Pizza.cs b/Pizzeria/PizzeriaDatabaseImplement/Models/Pizza.cs index b79d8e1..a32f628 100644 --- a/Pizzeria/PizzeriaDatabaseImplement/Models/Pizza.cs +++ b/Pizzeria/PizzeriaDatabaseImplement/Models/Pizza.cs @@ -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; diff --git a/Pizzeria/PizzeriaDatabaseImplement/PizzeriaDatabase.cs b/Pizzeria/PizzeriaDatabaseImplement/PizzeriaDatabase.cs index 65959f0..c071b87 100644 --- a/Pizzeria/PizzeriaDatabaseImplement/PizzeriaDatabase.cs +++ b/Pizzeria/PizzeriaDatabaseImplement/PizzeriaDatabase.cs @@ -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); } diff --git a/Pizzeria/PizzeriaDatabaseImplement/PizzeriaDatabaseImplement.csproj b/Pizzeria/PizzeriaDatabaseImplement/PizzeriaDatabaseImplement.csproj index 2b00238..738b64b 100644 --- a/Pizzeria/PizzeriaDatabaseImplement/PizzeriaDatabaseImplement.csproj +++ b/Pizzeria/PizzeriaDatabaseImplement/PizzeriaDatabaseImplement.csproj @@ -20,8 +20,4 @@ - - - -