Шаг 5.2 Reinforceds => Reinforcedies
This commit is contained in:
parent
f0ba13a71c
commit
48d3098e3c
@ -19,11 +19,11 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
using var context = new PrecastConcretePlantDataBase();
|
using var context = new PrecastConcretePlantDataBase();
|
||||||
|
|
||||||
var element = context.Reinforceds.Include(x => x.Components).FirstOrDefault(rec => rec.Id == model.Id);
|
var element = context.Reinforcedies.Include(x => x.Components).FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
context.Reinforceds.Remove(element);
|
context.Reinforcedies.Remove(element);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return element.GetViewModel;
|
return element.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
|
|||||||
|
|
||||||
using var context = new PrecastConcretePlantDataBase();
|
using var context = new PrecastConcretePlantDataBase();
|
||||||
|
|
||||||
return context.Reinforceds.Include(x => x.Components).ThenInclude(x => x.Component).FirstOrDefault(x => (!string.IsNullOrEmpty(model.ReinforcedName) && x.ReinforcedName == model.ReinforcedName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
return context.Reinforcedies.Include(x => x.Components).ThenInclude(x => x.Component).FirstOrDefault(x => (!string.IsNullOrEmpty(model.ReinforcedName) && x.ReinforcedName == model.ReinforcedName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReinforcedViewModel> GetFilteredList(ReinforcedSearchModel model)
|
public List<ReinforcedViewModel> GetFilteredList(ReinforcedSearchModel model)
|
||||||
@ -52,14 +52,14 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
|
|||||||
|
|
||||||
using var context = new PrecastConcretePlantDataBase();
|
using var context = new PrecastConcretePlantDataBase();
|
||||||
|
|
||||||
return context.Reinforceds.Include(x => x.Components).ThenInclude(x => x.Component).Where(x => x.ReinforcedName.Contains(model.ReinforcedName)).ToList().Select(x => x.GetViewModel).ToList();
|
return context.Reinforcedies.Include(x => x.Components).ThenInclude(x => x.Component).Where(x => x.ReinforcedName.Contains(model.ReinforcedName)).ToList().Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReinforcedViewModel> GetFullList()
|
public List<ReinforcedViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new PrecastConcretePlantDataBase();
|
using var context = new PrecastConcretePlantDataBase();
|
||||||
|
|
||||||
return context.Reinforceds.Include(x => x.Components).ThenInclude(x => x.Component).ToList().Select(x => x.GetViewModel).ToList();
|
return context.Reinforcedies.Include(x => x.Components).ThenInclude(x => x.Component).ToList().Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReinforcedViewModel? Insert(ReinforcedBindingModel model)
|
public ReinforcedViewModel? Insert(ReinforcedBindingModel model)
|
||||||
@ -73,7 +73,7 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Reinforceds.Add(newReinforced);
|
context.Reinforcedies.Add(newReinforced);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
|
||||||
return newReinforced.GetViewModel;
|
return newReinforced.GetViewModel;
|
||||||
@ -87,7 +87,7 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var reinforced = context.Reinforceds.FirstOrDefault(rec => rec.Id == model.Id);
|
var reinforced = context.Reinforcedies.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
|
||||||
if (reinforced == null)
|
if (reinforced == null)
|
||||||
{
|
{
|
||||||
|
@ -1,175 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using PrecastConcretePlantDatabaseImplement;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace PrecastConcretePlantDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(PrecastConcretePlantDataBase))]
|
|
||||||
[Migration("20230226175226_InitMigration")]
|
|
||||||
partial class InitMigration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "7.0.3")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ComponentName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Components");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<int>("ReinforcedId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("ReinforcedName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ReinforcedId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Reinforced", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<double>("Price")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.Property<string>("ReinforcedName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Reinforceds");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ReinforcedComponent", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("ComponentId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("ReinforcedId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ComponentId");
|
|
||||||
|
|
||||||
b.HasIndex("ReinforcedId");
|
|
||||||
|
|
||||||
b.ToTable("ReinforcedComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Reinforced", "Reinforced")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("ReinforcedId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Reinforced");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ReinforcedComponent", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Component", "Component")
|
|
||||||
.WithMany("ReinforcedComponents")
|
|
||||||
.HasForeignKey("ComponentId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Reinforced", "Reinforced")
|
|
||||||
.WithMany("Components")
|
|
||||||
.HasForeignKey("ReinforcedId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Component");
|
|
||||||
|
|
||||||
b.Navigation("Reinforced");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("ReinforcedComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Reinforced", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Components");
|
|
||||||
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace PrecastConcretePlantDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class AddClient : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "ClientId",
|
|
||||||
table: "Orders",
|
|
||||||
type: "int",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Clients",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_ClientId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "ClientId");
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_Orders_Clients_ClientId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "ClientId",
|
|
||||||
principalTable: "Clients",
|
|
||||||
principalColumn: "Id");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Orders_Clients_ClientId",
|
|
||||||
table: "Orders");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Clients");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_Orders_ClientId",
|
|
||||||
table: "Orders");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "ClientId",
|
|
||||||
table: "Orders");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,8 +12,8 @@ using PrecastConcretePlantDatabaseImplement;
|
|||||||
namespace PrecastConcretePlantDatabaseImplement.Migrations
|
namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(PrecastConcretePlantDataBase))]
|
[DbContext(typeof(PrecastConcretePlantDataBase))]
|
||||||
[Migration("20230326163223_AddClient")]
|
[Migration("20230326191118_Restart")]
|
||||||
partial class AddClient
|
partial class Restart
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -129,7 +129,7 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Reinforceds");
|
b.ToTable("Reinforcedies");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ReinforcedComponent", b =>
|
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ReinforcedComponent", b =>
|
@ -6,11 +6,26 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace PrecastConcretePlantDatabaseImplement.Migrations
|
namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class InitMigration : Migration
|
public partial class Restart : Migration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Clients",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Components",
|
name: "Components",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@ -26,7 +41,7 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
|||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Reinforceds",
|
name: "Reinforcedies",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
@ -36,7 +51,7 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Reinforceds", x => x.Id);
|
table.PrimaryKey("PK_Reinforcedies", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
@ -51,15 +66,21 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
|||||||
Sum = table.Column<double>(type: "float", nullable: false),
|
Sum = table.Column<double>(type: "float", nullable: false),
|
||||||
Status = table.Column<int>(type: "int", nullable: false),
|
Status = table.Column<int>(type: "int", nullable: false),
|
||||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||||
|
ClientId = table.Column<int>(type: "int", nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_Orders_Reinforceds_ReinforcedId",
|
name: "FK_Orders_Clients_ClientId",
|
||||||
|
column: x => x.ClientId,
|
||||||
|
principalTable: "Clients",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Orders_Reinforcedies_ReinforcedId",
|
||||||
column: x => x.ReinforcedId,
|
column: x => x.ReinforcedId,
|
||||||
principalTable: "Reinforceds",
|
principalTable: "Reinforcedies",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
@ -84,13 +105,18 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
|||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_ReinforcedComponents_Reinforceds_ReinforcedId",
|
name: "FK_ReinforcedComponents_Reinforcedies_ReinforcedId",
|
||||||
column: x => x.ReinforcedId,
|
column: x => x.ReinforcedId,
|
||||||
principalTable: "Reinforceds",
|
principalTable: "Reinforcedies",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_ClientId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ClientId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Orders_ReinforcedId",
|
name: "IX_Orders_ReinforcedId",
|
||||||
table: "Orders",
|
table: "Orders",
|
||||||
@ -116,11 +142,14 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
|||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "ReinforcedComponents");
|
name: "ReinforcedComponents");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Clients");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Components");
|
name: "Components");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Reinforceds");
|
name: "Reinforcedies");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -126,7 +126,7 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Reinforceds");
|
b.ToTable("Reinforcedies");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ReinforcedComponent", b =>
|
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ReinforcedComponent", b =>
|
||||||
|
@ -87,7 +87,7 @@ namespace PrecastConcretePlantDatabaseImplement.Models
|
|||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
var reinforced = context.Reinforceds.First(x => x.Id == Id);
|
var reinforced = context.Reinforcedies.First(x => x.Id == Id);
|
||||||
|
|
||||||
foreach (var pc in model.ReinforcedComponents)
|
foreach (var pc in model.ReinforcedComponents)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ namespace PrecastConcretePlantDatabaseImplement
|
|||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
public virtual DbSet<Component> Components { set; get; }
|
public virtual DbSet<Component> Components { set; get; }
|
||||||
public virtual DbSet<Reinforced> Reinforceds { set; get; }
|
public virtual DbSet<Reinforced> Reinforcedies { set; get; }
|
||||||
public virtual DbSet<ReinforcedComponent> ReinforcedComponents { set; get; }
|
public virtual DbSet<ReinforcedComponent> ReinforcedComponents { set; get; }
|
||||||
public virtual DbSet<Order> Orders { set; get; }
|
public virtual DbSet<Order> Orders { set; get; }
|
||||||
public virtual DbSet<Client> Clients { set; get; }
|
public virtual DbSet<Client> Clients { set; get; }
|
||||||
|
@ -18,7 +18,7 @@ namespace PrecastConcretePlantFileImplement
|
|||||||
private readonly string ClientFileName = "Client.xml";
|
private readonly string ClientFileName = "Client.xml";
|
||||||
public List<Component> Components { get; private set; }
|
public List<Component> Components { get; private set; }
|
||||||
public List<Order> Orders { get; private set; }
|
public List<Order> Orders { get; private set; }
|
||||||
public List<Reinforced> Reinforceds { get; private set; }
|
public List<Reinforced> Reinforcedies { get; private set; }
|
||||||
public List<Client> Clients { get; private set; }
|
public List<Client> Clients { get; private set; }
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
{
|
{
|
||||||
@ -30,8 +30,8 @@ namespace PrecastConcretePlantFileImplement
|
|||||||
}
|
}
|
||||||
public void SaveComponents() => SaveData(Components, ComponentFileName,
|
public void SaveComponents() => SaveData(Components, ComponentFileName,
|
||||||
"Components", x => x.GetXElement);
|
"Components", x => x.GetXElement);
|
||||||
public void SaveReinforceds() => SaveData(Reinforceds, ReinforcedFileName,
|
public void SaveReinforceds() => SaveData(Reinforcedies, ReinforcedFileName,
|
||||||
"Reinforceds", x => x.GetXElement);
|
"Reinforcedies", x => x.GetXElement);
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x
|
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x
|
||||||
=> x.GetXElement);
|
=> x.GetXElement);
|
||||||
public void SaveClients() => SaveData(Clients, OrderFileName, "Clients", x => x.GetXElement);
|
public void SaveClients() => SaveData(Clients, OrderFileName, "Clients", x => x.GetXElement);
|
||||||
@ -39,7 +39,7 @@ namespace PrecastConcretePlantFileImplement
|
|||||||
{
|
{
|
||||||
Components = LoadData(ComponentFileName, "Component", x =>
|
Components = LoadData(ComponentFileName, "Component", x =>
|
||||||
Component.Create(x)!)!;
|
Component.Create(x)!)!;
|
||||||
Reinforceds = LoadData(ReinforcedFileName, "Reinforced", x =>
|
Reinforcedies = LoadData(ReinforcedFileName, "Reinforced", x =>
|
||||||
Reinforced.Create(x)!)!;
|
Reinforced.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||||
|
@ -22,11 +22,11 @@ namespace PrecastConcretePlantFileImplement.Implements
|
|||||||
|
|
||||||
public ReinforcedViewModel? Delete(ReinforcedBindingModel model)
|
public ReinforcedViewModel? Delete(ReinforcedBindingModel model)
|
||||||
{
|
{
|
||||||
var element = source.Reinforceds.FirstOrDefault(x => x.Id == model.Id);
|
var element = source.Reinforcedies.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
source.Reinforceds.Remove(element);
|
source.Reinforcedies.Remove(element);
|
||||||
source.SaveReinforceds();
|
source.SaveReinforceds();
|
||||||
|
|
||||||
return element.GetViewModel;
|
return element.GetViewModel;
|
||||||
@ -42,7 +42,7 @@ namespace PrecastConcretePlantFileImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return source.Reinforceds.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ReinforcedName) && x.ReinforcedName == model.ReinforcedName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
return source.Reinforcedies.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ReinforcedName) && x.ReinforcedName == model.ReinforcedName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReinforcedViewModel> GetFilteredList(ReinforcedSearchModel model)
|
public List<ReinforcedViewModel> GetFilteredList(ReinforcedSearchModel model)
|
||||||
@ -52,17 +52,17 @@ namespace PrecastConcretePlantFileImplement.Implements
|
|||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
return source.Reinforceds.Where(x => x.ReinforcedName.Contains(model.ReinforcedName)).Select(x => x.GetViewModel).ToList();
|
return source.Reinforcedies.Where(x => x.ReinforcedName.Contains(model.ReinforcedName)).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReinforcedViewModel> GetFullList()
|
public List<ReinforcedViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
return source.Reinforceds.Select(x => x.GetViewModel).ToList();
|
return source.Reinforcedies.Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReinforcedViewModel? Insert(ReinforcedBindingModel model)
|
public ReinforcedViewModel? Insert(ReinforcedBindingModel model)
|
||||||
{
|
{
|
||||||
model.Id = source.Reinforceds.Count > 0 ? source.Reinforceds.Max(x => x.Id) + 1 : 1;
|
model.Id = source.Reinforcedies.Count > 0 ? source.Reinforcedies.Max(x => x.Id) + 1 : 1;
|
||||||
var newReinforced = Reinforced.Create(model);
|
var newReinforced = Reinforced.Create(model);
|
||||||
|
|
||||||
if (newReinforced == null)
|
if (newReinforced == null)
|
||||||
@ -70,7 +70,7 @@ namespace PrecastConcretePlantFileImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
source.Reinforceds.Add(newReinforced);
|
source.Reinforcedies.Add(newReinforced);
|
||||||
source.SaveReinforceds();
|
source.SaveReinforceds();
|
||||||
|
|
||||||
return newReinforced.GetViewModel;
|
return newReinforced.GetViewModel;
|
||||||
@ -78,7 +78,7 @@ namespace PrecastConcretePlantFileImplement.Implements
|
|||||||
|
|
||||||
public ReinforcedViewModel? Update(ReinforcedBindingModel model)
|
public ReinforcedViewModel? Update(ReinforcedBindingModel model)
|
||||||
{
|
{
|
||||||
var reinforced = source.Reinforceds.FirstOrDefault(x => x.Id == model.Id);
|
var reinforced = source.Reinforcedies.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
if (reinforced == null)
|
if (reinforced == null)
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,7 @@ namespace PrecastConcretePlantFileImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
ReinforcedId = ReinforcedId,
|
ReinforcedId = ReinforcedId,
|
||||||
ReinforcedName = ReinforcedName,
|
ReinforcedName = DataFileSingleton.GetInstance().Reinforcedies.FirstOrDefault(x => x.Id == ReinforcedId)?.ReinforcedName ?? string.Empty,
|
||||||
ClientFIO = DataFileSingleton.GetInstance().Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty,
|
ClientFIO = DataFileSingleton.GetInstance().Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
|
@ -12,13 +12,13 @@ namespace PrecastConcretePlantListImplement
|
|||||||
private static DataListSingleton? _instance;
|
private static DataListSingleton? _instance;
|
||||||
public List<Component> Components { get; set; }
|
public List<Component> Components { get; set; }
|
||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
public List<Reinforced> Reinforceds { get; set; }
|
public List<Reinforced> Reinforcedies { get; set; }
|
||||||
public List<Client> Clients { get; set; }
|
public List<Client> Clients { get; set; }
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
Components = new List<Component>();
|
Components = new List<Component>();
|
||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
Reinforceds = new List<Reinforced>();
|
Reinforcedies = new List<Reinforced>();
|
||||||
Clients = new List<Client>();
|
Clients = new List<Client>();
|
||||||
}
|
}
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
|
@ -128,11 +128,11 @@ namespace PrecastConcretePlantListImplement.Implements
|
|||||||
private OrderViewModel GetViewModel(Order model)
|
private OrderViewModel GetViewModel(Order model)
|
||||||
{
|
{
|
||||||
var res = model.GetViewModel;
|
var res = model.GetViewModel;
|
||||||
foreach (var pastry in _source.Reinforceds)
|
foreach (var reinforced in _source.Reinforcedies)
|
||||||
{
|
{
|
||||||
if (pastry.Id == model.ReinforcedId)
|
if (reinforced.Id == model.ReinforcedId)
|
||||||
{
|
{
|
||||||
res.ReinforcedName = pastry.ReinforcedName;
|
res.ReinforcedName = reinforced.ReinforcedName;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,12 @@ namespace PrecastConcretePlantListImplement.Implements
|
|||||||
|
|
||||||
public ReinforcedViewModel? Delete(ReinforcedBindingModel model)
|
public ReinforcedViewModel? Delete(ReinforcedBindingModel model)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _source.Reinforceds.Count; ++i)
|
for (int i = 0; i < _source.Reinforcedies.Count; ++i)
|
||||||
{
|
{
|
||||||
if (_source.Reinforceds[i].Id == model.Id)
|
if (_source.Reinforcedies[i].Id == model.Id)
|
||||||
{
|
{
|
||||||
var element = _source.Reinforceds[i];
|
var element = _source.Reinforcedies[i];
|
||||||
_source.Reinforceds.RemoveAt(i);
|
_source.Reinforcedies.RemoveAt(i);
|
||||||
return element.GetViewModel;
|
return element.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ namespace PrecastConcretePlantListImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var reinforced in _source.Reinforceds)
|
foreach (var reinforced in _source.Reinforcedies)
|
||||||
{
|
{
|
||||||
if ((!string.IsNullOrEmpty(model.ReinforcedName) && reinforced.ReinforcedName == model.ReinforcedName) || (model.Id.HasValue && reinforced.Id == model.Id))
|
if ((!string.IsNullOrEmpty(model.ReinforcedName) && reinforced.ReinforcedName == model.ReinforcedName) || (model.Id.HasValue && reinforced.Id == model.Id))
|
||||||
{
|
{
|
||||||
@ -62,7 +62,7 @@ namespace PrecastConcretePlantListImplement.Implements
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var reinforced in _source.Reinforceds)
|
foreach (var reinforced in _source.Reinforcedies)
|
||||||
{
|
{
|
||||||
if (reinforced.ReinforcedName.Contains(model.ReinforcedName))
|
if (reinforced.ReinforcedName.Contains(model.ReinforcedName))
|
||||||
{
|
{
|
||||||
@ -77,7 +77,7 @@ namespace PrecastConcretePlantListImplement.Implements
|
|||||||
{
|
{
|
||||||
var result = new List<ReinforcedViewModel>();
|
var result = new List<ReinforcedViewModel>();
|
||||||
|
|
||||||
foreach (var reinforced in _source.Reinforceds)
|
foreach (var reinforced in _source.Reinforcedies)
|
||||||
{
|
{
|
||||||
result.Add(reinforced.GetViewModel);
|
result.Add(reinforced.GetViewModel);
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ namespace PrecastConcretePlantListImplement.Implements
|
|||||||
{
|
{
|
||||||
model.Id = 1;
|
model.Id = 1;
|
||||||
|
|
||||||
foreach (var reinforced in _source.Reinforceds)
|
foreach (var reinforced in _source.Reinforcedies)
|
||||||
{
|
{
|
||||||
if (model.Id <= reinforced.Id)
|
if (model.Id <= reinforced.Id)
|
||||||
{
|
{
|
||||||
@ -104,14 +104,14 @@ namespace PrecastConcretePlantListImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_source.Reinforceds.Add(newReinforced);
|
_source.Reinforcedies.Add(newReinforced);
|
||||||
|
|
||||||
return newReinforced.GetViewModel;
|
return newReinforced.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReinforcedViewModel? Update(ReinforcedBindingModel model)
|
public ReinforcedViewModel? Update(ReinforcedBindingModel model)
|
||||||
{
|
{
|
||||||
foreach (var reinforced in _source.Reinforceds)
|
foreach (var reinforced in _source.Reinforcedies)
|
||||||
{
|
{
|
||||||
if (reinforced.Id == model.Id)
|
if (reinforced.Id == model.Id)
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,7 @@ namespace PrecastConcretePlantRestApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<ReinforcedViewModel>? GetPastryList()
|
public List<ReinforcedViewModel>? GetReinforcedList()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -38,15 +38,15 @@ namespace PrecastConcretePlantRestApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ReinforcedViewModel? GetPastry(int PastryId)
|
public ReinforcedViewModel? GetReinforced(int ReinforcedId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _reinforced.ReadElement(new ReinforcedSearchModel { Id = PastryId });
|
return _reinforced.ReadElement(new ReinforcedSearchModel { Id = ReinforcedId });
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка получения изделия по id={Id}", PastryId);
|
_logger.LogError(ex, "Ошибка получения изделия по id={Id}", ReinforcedId);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user