Kashin M.I. Lab work 5 base #7
@ -14,7 +14,7 @@ namespace PrecastConcretePlantClientApp.Controllers
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
|
@ -19,11 +19,11 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
|
||||
{
|
||||
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)
|
||||
{
|
||||
context.Reinforceds.Remove(element);
|
||||
context.Reinforcedies.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
@ -40,7 +40,7 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
|
||||
|
||||
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)
|
||||
@ -52,14 +52,14 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
|
||||
|
||||
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()
|
||||
{
|
||||
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)
|
||||
@ -73,7 +73,7 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Reinforceds.Add(newReinforced);
|
||||
context.Reinforcedies.Add(newReinforced);
|
||||
context.SaveChanges();
|
||||
|
||||
return newReinforced.GetViewModel;
|
||||
@ -87,7 +87,7 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
|
||||
|
||||
try
|
||||
{
|
||||
var reinforced = context.Reinforceds.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var reinforced = context.Reinforcedies.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
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
|
||||
{
|
||||
[DbContext(typeof(PrecastConcretePlantDataBase))]
|
||||
[Migration("20230326163223_AddClient")]
|
||||
partial class AddClient
|
||||
[Migration("20230326191118_Restart")]
|
||||
partial class Restart
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -129,7 +129,7 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Reinforceds");
|
||||
b.ToTable("Reinforcedies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ReinforcedComponent", b =>
|
@ -6,11 +6,26 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitMigration : Migration
|
||||
public partial class Restart : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
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(
|
||||
name: "Components",
|
||||
columns: table => new
|
||||
@ -26,7 +41,7 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Reinforceds",
|
||||
name: "Reinforcedies",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
@ -36,7 +51,7 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Reinforceds", x => x.Id);
|
||||
table.PrimaryKey("PK_Reinforcedies", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -51,15 +66,21 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||
Sum = table.Column<double>(type: "float", nullable: false),
|
||||
Status = table.Column<int>(type: "int", 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 =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
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,
|
||||
principalTable: "Reinforceds",
|
||||
principalTable: "Reinforcedies",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
@ -84,13 +105,18 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ReinforcedComponents_Reinforceds_ReinforcedId",
|
||||
name: "FK_ReinforcedComponents_Reinforcedies_ReinforcedId",
|
||||
column: x => x.ReinforcedId,
|
||||
principalTable: "Reinforceds",
|
||||
principalTable: "Reinforcedies",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ReinforcedId",
|
||||
table: "Orders",
|
||||
@ -116,11 +142,14 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "ReinforcedComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Reinforceds");
|
||||
name: "Reinforcedies");
|
||||
}
|
||||
}
|
||||
}
|
@ -126,7 +126,7 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Reinforceds");
|
||||
b.ToTable("Reinforcedies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ReinforcedComponent", b =>
|
||||
|
@ -87,7 +87,7 @@ namespace PrecastConcretePlantDatabaseImplement.Models
|
||||
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)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ namespace PrecastConcretePlantDatabaseImplement
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
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<Order> Orders { set; get; }
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
|
@ -18,7 +18,7 @@ namespace PrecastConcretePlantFileImplement
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
public List<Component> Components { 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 static DataFileSingleton GetInstance()
|
||||
{
|
||||
@ -30,8 +30,8 @@ namespace PrecastConcretePlantFileImplement
|
||||
}
|
||||
public void SaveComponents() => SaveData(Components, ComponentFileName,
|
||||
"Components", x => x.GetXElement);
|
||||
public void SaveReinforceds() => SaveData(Reinforceds, ReinforcedFileName,
|
||||
"Reinforceds", x => x.GetXElement);
|
||||
public void SaveReinforceds() => SaveData(Reinforcedies, ReinforcedFileName,
|
||||
"Reinforcedies", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x
|
||||
=> x.GetXElement);
|
||||
public void SaveClients() => SaveData(Clients, OrderFileName, "Clients", x => x.GetXElement);
|
||||
@ -39,7 +39,7 @@ namespace PrecastConcretePlantFileImplement
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x =>
|
||||
Component.Create(x)!)!;
|
||||
Reinforceds = LoadData(ReinforcedFileName, "Reinforced", x =>
|
||||
Reinforcedies = LoadData(ReinforcedFileName, "Reinforced", x =>
|
||||
Reinforced.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||
|
@ -22,11 +22,11 @@ namespace PrecastConcretePlantFileImplement.Implements
|
||||
|
||||
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)
|
||||
{
|
||||
source.Reinforceds.Remove(element);
|
||||
source.Reinforcedies.Remove(element);
|
||||
source.SaveReinforceds();
|
||||
|
||||
return element.GetViewModel;
|
||||
@ -42,7 +42,7 @@ namespace PrecastConcretePlantFileImplement.Implements
|
||||
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)
|
||||
@ -52,17 +52,17 @@ namespace PrecastConcretePlantFileImplement.Implements
|
||||
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()
|
||||
{
|
||||
return source.Reinforceds.Select(x => x.GetViewModel).ToList();
|
||||
return source.Reinforcedies.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (newReinforced == null)
|
||||
@ -70,7 +70,7 @@ namespace PrecastConcretePlantFileImplement.Implements
|
||||
return null;
|
||||
}
|
||||
|
||||
source.Reinforceds.Add(newReinforced);
|
||||
source.Reinforcedies.Add(newReinforced);
|
||||
source.SaveReinforceds();
|
||||
|
||||
return newReinforced.GetViewModel;
|
||||
@ -78,7 +78,7 @@ namespace PrecastConcretePlantFileImplement.Implements
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ namespace PrecastConcretePlantFileImplement.Models
|
||||
{
|
||||
Id = Id,
|
||||
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,
|
||||
ClientId = ClientId,
|
||||
Count = Count,
|
||||
|
@ -12,13 +12,13 @@ namespace PrecastConcretePlantListImplement
|
||||
private static DataListSingleton? _instance;
|
||||
public List<Component> Components { 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; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Reinforceds = new List<Reinforced>();
|
||||
Reinforcedies = new List<Reinforced>();
|
||||
Clients = new List<Client>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
|
@ -128,11 +128,11 @@ namespace PrecastConcretePlantListImplement.Implements
|
||||
private OrderViewModel GetViewModel(Order model)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -22,12 +22,12 @@ namespace PrecastConcretePlantListImplement.Implements
|
||||
|
||||
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];
|
||||
_source.Reinforceds.RemoveAt(i);
|
||||
var element = _source.Reinforcedies[i];
|
||||
_source.Reinforcedies.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,7 @@ namespace PrecastConcretePlantListImplement.Implements
|
||||
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))
|
||||
{
|
||||
@ -62,7 +62,7 @@ namespace PrecastConcretePlantListImplement.Implements
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var reinforced in _source.Reinforceds)
|
||||
foreach (var reinforced in _source.Reinforcedies)
|
||||
{
|
||||
if (reinforced.ReinforcedName.Contains(model.ReinforcedName))
|
||||
{
|
||||
@ -77,7 +77,7 @@ namespace PrecastConcretePlantListImplement.Implements
|
||||
{
|
||||
var result = new List<ReinforcedViewModel>();
|
||||
|
||||
foreach (var reinforced in _source.Reinforceds)
|
||||
foreach (var reinforced in _source.Reinforcedies)
|
||||
{
|
||||
result.Add(reinforced.GetViewModel);
|
||||
}
|
||||
@ -89,7 +89,7 @@ namespace PrecastConcretePlantListImplement.Implements
|
||||
{
|
||||
model.Id = 1;
|
||||
|
||||
foreach (var reinforced in _source.Reinforceds)
|
||||
foreach (var reinforced in _source.Reinforcedies)
|
||||
{
|
||||
if (model.Id <= reinforced.Id)
|
||||
{
|
||||
@ -104,14 +104,14 @@ namespace PrecastConcretePlantListImplement.Implements
|
||||
return null;
|
||||
}
|
||||
|
||||
_source.Reinforceds.Add(newReinforced);
|
||||
_source.Reinforcedies.Add(newReinforced);
|
||||
|
||||
return newReinforced.GetViewModel;
|
||||
}
|
||||
|
||||
public ReinforcedViewModel? Update(ReinforcedBindingModel model)
|
||||
{
|
||||
foreach (var reinforced in _source.Reinforceds)
|
||||
foreach (var reinforced in _source.Reinforcedies)
|
||||
{
|
||||
if (reinforced.Id == model.Id)
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ namespace PrecastConcretePlantRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ReinforcedViewModel>? GetPastryList()
|
||||
public List<ReinforcedViewModel>? GetReinforcedList()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -38,15 +38,15 @@ namespace PrecastConcretePlantRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ReinforcedViewModel? GetPastry(int PastryId)
|
||||
public ReinforcedViewModel? GetReinforced(int ReinforcedId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _reinforced.ReadElement(new ReinforcedSearchModel { Id = PastryId });
|
||||
return _reinforced.ReadElement(new ReinforcedSearchModel { Id = ReinforcedId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения изделия по id={Id}", PastryId);
|
||||
_logger.LogError(ex, "Ошибка получения изделия по id={Id}", ReinforcedId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user