Исправление имен
This commit is contained in:
parent
e962963589
commit
eaafd9b703
@ -12,7 +12,7 @@ namespace SushiBarDatabaseImplement.Implements
|
|||||||
public List<SushiViewModel> GetFullList()
|
public List<SushiViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new SushiBarDatabase();
|
using var context = new SushiBarDatabase();
|
||||||
return context.SushiList
|
return context.ListSushi
|
||||||
.Include(x => x.Ingredients)
|
.Include(x => x.Ingredients)
|
||||||
.ThenInclude(x => x.Ingredient)
|
.ThenInclude(x => x.Ingredient)
|
||||||
.ToList()
|
.ToList()
|
||||||
@ -27,7 +27,7 @@ namespace SushiBarDatabaseImplement.Implements
|
|||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
using var context = new SushiBarDatabase();
|
using var context = new SushiBarDatabase();
|
||||||
return context.SushiList
|
return context.ListSushi
|
||||||
.Include(x => x.Ingredients)
|
.Include(x => x.Ingredients)
|
||||||
.ThenInclude(x => x.Ingredient)
|
.ThenInclude(x => x.Ingredient)
|
||||||
.Where(x => x.SushiName.Contains(model.SushiName))
|
.Where(x => x.SushiName.Contains(model.SushiName))
|
||||||
@ -43,7 +43,7 @@ namespace SushiBarDatabaseImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new SushiBarDatabase();
|
using var context = new SushiBarDatabase();
|
||||||
return context.SushiList
|
return context.ListSushi
|
||||||
.Include(x => x.Ingredients)
|
.Include(x => x.Ingredients)
|
||||||
.ThenInclude(x => x.Ingredient)
|
.ThenInclude(x => x.Ingredient)
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.SushiName) && x.SushiName == model.SushiName) ||
|
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.SushiName) && x.SushiName == model.SushiName) ||
|
||||||
@ -59,7 +59,7 @@ namespace SushiBarDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
context.SushiList.Add(newSushi);
|
context.ListSushi.Add(newSushi);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return newSushi.GetViewModel;
|
return newSushi.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ namespace SushiBarDatabaseImplement.Implements
|
|||||||
using var transaction = context.Database.BeginTransaction();
|
using var transaction = context.Database.BeginTransaction();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sushi = context.SushiList.FirstOrDefault(rec => rec.Id == model.Id);
|
var sushi = context.ListSushi.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
if (sushi == null)
|
if (sushi == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -91,13 +91,13 @@ namespace SushiBarDatabaseImplement.Implements
|
|||||||
public SushiViewModel? Delete(SushiBindingModel model)
|
public SushiViewModel? Delete(SushiBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new SushiBarDatabase();
|
using var context = new SushiBarDatabase();
|
||||||
var element = context.SushiList
|
var element = context.ListSushi
|
||||||
.Include(x => x.Ingredients)
|
.Include(x => x.Ingredients)
|
||||||
.Include(x => x.Orders)
|
.Include(x => x.Orders)
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
context.SushiList.Remove(element);
|
context.ListSushi.Remove(element);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return element.GetViewModel;
|
return element.GetViewModel;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("SushiList");
|
b.ToTable("ListSushi");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiIngredient", b =>
|
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiIngredient", b =>
|
||||||
|
@ -44,7 +44,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
|||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "SushiList",
|
name: "ListSushi",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
@ -54,7 +54,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_SushiList", x => x.Id);
|
table.PrimaryKey("PK_ListSushi", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
@ -77,9 +77,9 @@ namespace SushiBarDatabaseImplement.Migrations
|
|||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_SushiIngredients_SushiList_SushiId",
|
name: "FK_SushiIngredients_ListSushi_SushiId",
|
||||||
column: x => x.SushiId,
|
column: x => x.SushiId,
|
||||||
principalTable: "SushiList",
|
principalTable: "ListSushi",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
@ -108,7 +108,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
|||||||
name: "Ingredients");
|
name: "Ingredients");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "SushiList");
|
name: "ListSushi");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("SushiList");
|
b.ToTable("ListSushi");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiIngredient", b =>
|
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiIngredient", b =>
|
||||||
|
@ -16,10 +16,10 @@ namespace SushiBarDatabaseImplement.Migrations
|
|||||||
column: "SushiId");
|
column: "SushiId");
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
migrationBuilder.AddForeignKey(
|
||||||
name: "FK_Orders_SushiList_SushiId",
|
name: "FK_Orders_ListSushi_SushiId",
|
||||||
table: "Orders",
|
table: "Orders",
|
||||||
column: "SushiId",
|
column: "SushiId",
|
||||||
principalTable: "SushiList",
|
principalTable: "ListSushi",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
|||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropForeignKey(
|
migrationBuilder.DropForeignKey(
|
||||||
name: "FK_Orders_SushiList_SushiId",
|
name: "FK_Orders_ListSushi_SushiId",
|
||||||
table: "Orders");
|
table: "Orders");
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
migrationBuilder.DropIndex(
|
||||||
|
@ -88,7 +88,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("SushiList");
|
b.ToTable("ListSushi");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiIngredient", b =>
|
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiIngredient", b =>
|
||||||
|
@ -81,7 +81,7 @@ namespace SushiBarDatabaseImplement.Models
|
|||||||
}
|
}
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
var sushi = context.SushiList.First(x => x.Id == Id);
|
var sushi = context.ListSushi.First(x => x.Id == Id);
|
||||||
foreach (var si in model.SushiIngredients)
|
foreach (var si in model.SushiIngredients)
|
||||||
{
|
{
|
||||||
context.SushiIngredients.Add(new SushiIngredient
|
context.SushiIngredients.Add(new SushiIngredient
|
||||||
|
@ -16,7 +16,7 @@ namespace SushiBarDatabaseImplement
|
|||||||
|
|
||||||
public virtual DbSet<Ingredient> Ingredients { set; get; }
|
public virtual DbSet<Ingredient> Ingredients { set; get; }
|
||||||
|
|
||||||
public virtual DbSet<Sushi> SushiList { set; get; }
|
public virtual DbSet<Sushi> ListSushi { set; get; }
|
||||||
|
|
||||||
public virtual DbSet<SushiIngredient> SushiIngredients { set; get; }
|
public virtual DbSet<SushiIngredient> SushiIngredients { set; get; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user