Zacharchenko Lab work 3 Hard #8

Closed
shadowik wants to merge 6 commits from Lab3_Hard into Lab2_Hard
5 changed files with 5 additions and 11 deletions
Showing only changes of commit 8cde12c752 - Show all commits

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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);
}

View File

@ -20,8 +20,4 @@
<ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project>