This commit is contained in:
VictoriaPresnyakova 2023-03-05 19:31:05 +04:00
parent c7bcc08419
commit a24cc96236
12 changed files with 1002 additions and 9 deletions

View File

@ -25,6 +25,7 @@
<ItemGroup>
<ProjectReference Include="..\JewelryStoreBusinessLogic\JewelryStoreBusinessLogic.csproj" />
<ProjectReference Include="..\JewelryStoreContracts\JewelryStoreContracts.csproj" />
<ProjectReference Include="..\JewelryStoreDatabaseImplement\JewelryStoreDatabaseImplement.csproj" />
<ProjectReference Include="..\JewelryStoreFileImplement\JewelryStoreFileImplement.csproj" />
<ProjectReference Include="..\JewelryStoreListImplement\JewelryStoreListImplement.csproj" />
</ItemGroup>

View File

@ -1,7 +1,7 @@
using JewelryStoreContracts.BusinessLogicsContracts;
using JewelryStoreContracts.StoragesContracts;
using JewelryStoreBusinessLogic.BusinessLogics;
using JewelryStoreFileImplement.Implements;
using JewelryStoreDatabaseImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using System.Drawing;

View File

@ -0,0 +1,98 @@
using JewelryStoreContracts.BindingModels;
using JewelryStoreContracts.SearchModels;
using JewelryStoreContracts.StoragesContracts;
using JewelryStoreContracts.ViewModels;
using JewelryStoreDatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JewelryStoreDatabaseImplement.Implements
{
public class ComponentStorage : IComponentStorage
{
public ComponentViewModel? Delete(ComponentBindingModel model)
{
using var context = new JewelryStoreDataBase();
var element = context.Components.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Components.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public ComponentViewModel? GetElement(ComponentSearchModel model)
{
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
{
return null;
}
using var context = new JewelryStoreDataBase();
return context.Components.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
{
if (string.IsNullOrEmpty(model.ComponentName))
{
return new();
}
using var context = new JewelryStoreDataBase();
return context.Components.Where(x => x.ComponentName.Contains(model.ComponentName)).Select(x => x.GetViewModel).ToList();
}
public List<ComponentViewModel> GetFullList()
{
using var context = new JewelryStoreDataBase();
return context.Components.Select(x => x.GetViewModel).ToList();
}
public ComponentViewModel? Insert(ComponentBindingModel model)
{
var newComponent = Component.Create(model);
if (newComponent == null)
{
return null;
}
using var context = new JewelryStoreDataBase();
context.Components.Add(newComponent);
context.SaveChanges();
return newComponent.GetViewModel;
}
public ComponentViewModel? Update(ComponentBindingModel model)
{
using var context = new JewelryStoreDataBase();
var component = context.Components.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
}
}

View File

@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JewelryStoreContracts.BindingModels;
using JewelryStoreContracts.SearchModels;
using JewelryStoreContracts.StoragesContracts;
using JewelryStoreContracts.ViewModels;
using JewelryStoreDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace JewelryStoreDatabaseImplement.Implements
{
public class JewelStorage : IJewelStorage
{
public JewelViewModel? Delete(JewelBindingModel model)
{
using var context = new JewelryStoreDataBase();
var element = context.Jewels.Include(x => x.Components).FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Jewels.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public JewelViewModel? GetElement(JewelSearchModel model)
{
if (string.IsNullOrEmpty(model.JewelName) && !model.Id.HasValue)
{
return null;
}
using var context = new JewelryStoreDataBase();
return context.Jewels.Include(x => x.Components).ThenInclude(x => x.Component).FirstOrDefault(x => (!string.IsNullOrEmpty(model.JewelName) && x.JewelName == model.JewelName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public List<JewelViewModel> GetFilteredList(JewelSearchModel model)
{
if (string.IsNullOrEmpty(model.JewelName))
{
return new();
}
using var context = new JewelryStoreDataBase();
return context.Jewels.Include(x => x.Components).ThenInclude(x => x.Component).Where(x => x.JewelName.Contains(model.JewelName)).ToList().Select(x => x.GetViewModel).ToList();
}
public List<JewelViewModel> GetFullList()
{
using var context = new JewelryStoreDataBase();
return context.Jewels.Include(x => x.Components).ThenInclude(x => x.Component).ToList().Select(x => x.GetViewModel).ToList();
}
public JewelViewModel? Insert(JewelBindingModel model)
{
using var context = new JewelryStoreDataBase();
var newJewel = Jewel.Create(context, model);
if (newJewel == null)
{
return null;
}
context.Jewels.Add(newJewel);
context.SaveChanges();
return newJewel.GetViewModel;
}
public JewelViewModel? Update(JewelBindingModel model)
{
using var context = new JewelryStoreDataBase();
using var transaction = context.Database.BeginTransaction();
try
{
var jewel = context.Jewels.FirstOrDefault(rec => rec.Id == model.Id);
if (jewel == null)
{
return null;
}
jewel.Update(model);
context.SaveChanges();
jewel.UpdateComponents(context, model);
transaction.Commit();
return jewel.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
}
}

View File

@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JewelryStoreContracts.BindingModels;
using JewelryStoreContracts.SearchModels;
using JewelryStoreContracts.StoragesContracts;
using JewelryStoreContracts.ViewModels;
using JewelryStoreDatabaseImplement.Models;
namespace JewelryStoreDatabaseImplement.Implements
{
public class OrderStorage : IOrderStorage
{
public OrderViewModel? Delete(OrderBindingModel model)
{
using var context = new JewelryStoreDataBase();
var element = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Orders.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new JewelryStoreDataBase();
return context.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return new();
}
using var context = new JewelryStoreDataBase();
return context.Orders.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
}
public List<OrderViewModel> GetFullList()
{
using var context = new JewelryStoreDataBase();
return context.Orders.Select(x => x.GetViewModel).ToList();
}
public OrderViewModel? Insert(OrderBindingModel model)
{
var newOrder = Order.Create(model);
if (newOrder == null)
{
return null;
}
using var context = new JewelryStoreDataBase();
context.Orders.Add(newOrder);
context.SaveChanges();
return newOrder.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
{
using var context = new JewelryStoreDataBase();
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
if (order == null)
{
return null;
}
order.Update(model);
context.SaveChanges();
return order.GetViewModel;
}
}
}

View File

@ -1,12 +1,30 @@
using System;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JewelryStoreDatabaseImplement.Models;
namespace JewelryStoreDatabaseImplement
{
public class JewelryStoreDataBase
public class JewelryStoreDataBase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-H890EHR\SQLEXPRESS;Initial Catalog=JewelryStoreDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Component> Components { set; get; }
public virtual DbSet<Jewel> Jewels { set; get; }
public virtual DbSet<JewelComponent> JewelComponents { set; get; }
public virtual DbSet<Order> Orders { set; get; }
}
}

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
@ -11,10 +11,6 @@
<ProjectReference Include="..\JewelryStoreDataModels\JewelryStoreDataModels.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Implements\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.3" />

View File

@ -0,0 +1,175 @@
// <auto-generated />
using System;
using JewelryStoreDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace JewelryStoreDatabaseImplement.Migrations
{
[DbContext(typeof(JewelryStoreDataBase))]
[Migration("20230305150151_InitialCreate")]
partial class InitialCreate
{
/// <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("JewelryStoreDatabaseImplement.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("JewelryStoreDatabaseImplement.Models.Jewel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("JewelName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Jewels");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.JewelComponent", 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>("JewelId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("JewelId");
b.ToTable("JewelComponents");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.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>("JewelId")
.HasColumnType("int");
b.Property<string>("JewelName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("JewelId");
b.ToTable("Orders");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.JewelComponent", b =>
{
b.HasOne("JewelryStoreDatabaseImplement.Models.Component", "Component")
.WithMany("JewelComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("JewelryStoreDatabaseImplement.Models.Jewel", "Jewel")
.WithMany("Components")
.HasForeignKey("JewelId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Jewel");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.Order", b =>
{
b.HasOne("JewelryStoreDatabaseImplement.Models.Jewel", "Jewel")
.WithMany("Orders")
.HasForeignKey("JewelId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Jewel");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.Component", b =>
{
b.Navigation("JewelComponents");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.Jewel", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,126 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace JewelryStoreDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Components",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Cost = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Components", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Jewels",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
JewelName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Price = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Jewels", x => x.Id);
});
migrationBuilder.CreateTable(
name: "JewelComponents",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
JewelId = table.Column<int>(type: "int", nullable: false),
ComponentId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_JewelComponents", x => x.Id);
table.ForeignKey(
name: "FK_JewelComponents_Components_ComponentId",
column: x => x.ComponentId,
principalTable: "Components",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_JewelComponents_Jewels_JewelId",
column: x => x.JewelId,
principalTable: "Jewels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
JewelId = table.Column<int>(type: "int", nullable: false),
JewelName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Count = table.Column<int>(type: "int", nullable: false),
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)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey(
name: "FK_Orders_Jewels_JewelId",
column: x => x.JewelId,
principalTable: "Jewels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_JewelComponents_ComponentId",
table: "JewelComponents",
column: "ComponentId");
migrationBuilder.CreateIndex(
name: "IX_JewelComponents_JewelId",
table: "JewelComponents",
column: "JewelId");
migrationBuilder.CreateIndex(
name: "IX_Orders_JewelId",
table: "Orders",
column: "JewelId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "JewelComponents");
migrationBuilder.DropTable(
name: "Orders");
migrationBuilder.DropTable(
name: "Components");
migrationBuilder.DropTable(
name: "Jewels");
}
}
}

View File

@ -0,0 +1,175 @@
// <auto-generated />
using System;
using JewelryStoreDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace JewelryStoreDatabaseImplement.Migrations
{
[DbContext(typeof(JewelryStoreDataBase))]
[Migration("20230305150722_InitialCreate_1")]
partial class InitialCreate_1
{
/// <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("JewelryStoreDatabaseImplement.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("JewelryStoreDatabaseImplement.Models.Jewel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("JewelName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Jewels");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.JewelComponent", 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>("JewelId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("JewelId");
b.ToTable("JewelComponents");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.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>("JewelId")
.HasColumnType("int");
b.Property<string>("JewelName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("JewelId");
b.ToTable("Orders");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.JewelComponent", b =>
{
b.HasOne("JewelryStoreDatabaseImplement.Models.Component", "Component")
.WithMany("JewelComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("JewelryStoreDatabaseImplement.Models.Jewel", "Jewel")
.WithMany("Components")
.HasForeignKey("JewelId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Jewel");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.Order", b =>
{
b.HasOne("JewelryStoreDatabaseImplement.Models.Jewel", "Jewel")
.WithMany("Orders")
.HasForeignKey("JewelId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Jewel");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.Component", b =>
{
b.Navigation("JewelComponents");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.Jewel", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace JewelryStoreDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate_1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,172 @@
// <auto-generated />
using System;
using JewelryStoreDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace JewelryStoreDatabaseImplement.Migrations
{
[DbContext(typeof(JewelryStoreDataBase))]
partial class JewelryStoreDataBaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("JewelryStoreDatabaseImplement.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("JewelryStoreDatabaseImplement.Models.Jewel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("JewelName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Jewels");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.JewelComponent", 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>("JewelId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("JewelId");
b.ToTable("JewelComponents");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.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>("JewelId")
.HasColumnType("int");
b.Property<string>("JewelName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("JewelId");
b.ToTable("Orders");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.JewelComponent", b =>
{
b.HasOne("JewelryStoreDatabaseImplement.Models.Component", "Component")
.WithMany("JewelComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("JewelryStoreDatabaseImplement.Models.Jewel", "Jewel")
.WithMany("Components")
.HasForeignKey("JewelId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Jewel");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.Order", b =>
{
b.HasOne("JewelryStoreDatabaseImplement.Models.Jewel", "Jewel")
.WithMany("Orders")
.HasForeignKey("JewelId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Jewel");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.Component", b =>
{
b.Navigation("JewelComponents");
});
modelBuilder.Entity("JewelryStoreDatabaseImplement.Models.Jewel", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}