LabWork03 is presumably done.
This commit is contained in:
parent
8caaddfbfd
commit
f070f327a4
@ -15,9 +15,7 @@ namespace DressAtelierDatabaseImplementation
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data
|
||||
Source=DESKTOP-7QJ9UJE\SQLEXPRESS;Initial Catalog=DressAtelierDatabaseFull;Integrated
|
||||
Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-7QJ9UJE\SQLEXPRESS;Initial Catalog=DressAtelierDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -0,0 +1,91 @@
|
||||
using DressAtelierContracts.BindingModels;
|
||||
using DressAtelierContracts.SearchModels;
|
||||
using DressAtelierContracts.StorageContracts;
|
||||
using DressAtelierContracts.ViewModels;
|
||||
using DressAtelierDatabaseImplementation.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DressAtelierDatabaseImplementation.Implements
|
||||
{
|
||||
public class DressStorage : IDressStorage
|
||||
{
|
||||
public List<DressViewModel> GetFullList()
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
return context.Dresses.Include(x => x.Materials).ThenInclude(x => x.Material).ToList().Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<DressViewModel> GetFilteredList(DressSearchModel model)
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
return context.Dresses.Include(x => x.Materials).ThenInclude(x => x.Material).Where(x => x.ID == model.ID).ToList().Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public DressViewModel? GetElement(DressSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.DressName) && !model.ID.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new DressAtelierDatabase();
|
||||
return context.Dresses.Include(x => x.Materials).ThenInclude(x => x.Material).FirstOrDefault(x => !string.IsNullOrEmpty(model.DressName) ? x.DressName.Contains(model.DressName) : x.ID == model.ID).GetViewModel;
|
||||
}
|
||||
|
||||
public DressViewModel? Insert(DressBindingModel model)
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
var newDress = Dress.Create(context,model);
|
||||
if (newDress == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Dresses.Add(newDress);
|
||||
context.SaveChanges();
|
||||
return newDress.GetViewModel;
|
||||
}
|
||||
|
||||
public DressViewModel? Update(DressBindingModel model)
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var dress = context.Dresses.FirstOrDefault(x => x.ID == model.ID);
|
||||
if(dress == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
dress.Update(model);
|
||||
context.SaveChanges();
|
||||
dress.UpdateComponents(context, model);
|
||||
transaction.Commit();
|
||||
return dress.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public DressViewModel? Delete(DressBindingModel model)
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
var dress = context.Dresses.Include(x => x.Materials).FirstOrDefault(x => x.ID == model.ID);
|
||||
if(dress == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Dresses.Remove(dress);
|
||||
context.SaveChanges();
|
||||
return dress.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
using DressAtelierContracts.BindingModels;
|
||||
using DressAtelierContracts.SearchModels;
|
||||
using DressAtelierContracts.StorageContracts;
|
||||
using DressAtelierContracts.ViewModels;
|
||||
using DressAtelierDatabaseImplementation.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DressAtelierDatabaseImplementation.Implements
|
||||
{
|
||||
public class MaterialStorage : IMaterialStorage
|
||||
{
|
||||
|
||||
public List<MaterialViewModel> GetFullList()
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
return context.Materials.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<MaterialViewModel> GetFilteredList(MaterialSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ComponentName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new DressAtelierDatabase();
|
||||
return context.Materials.Where(x => x.ComponentName.Contains(model.ComponentName)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public MaterialViewModel? GetElement(MaterialSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.ID.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new DressAtelierDatabase();
|
||||
return context.Materials.FirstOrDefault(x => !string.IsNullOrEmpty(model.ComponentName) ? x.ComponentName.Contains(model.ComponentName) : x.ID == model.ID).GetViewModel;
|
||||
}
|
||||
|
||||
public MaterialViewModel? Insert(MaterialBindingModel model)
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
var newComponent = Material.Create(model);
|
||||
if (newComponent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Materials.Add(newComponent);
|
||||
context.SaveChanges();
|
||||
return newComponent.GetViewModel;
|
||||
}
|
||||
|
||||
public MaterialViewModel? Update(MaterialBindingModel model)
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
var material = context.Materials.FirstOrDefault(x => x.ID == model.ID);
|
||||
if(material == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
material.Update(model);
|
||||
context.SaveChanges();
|
||||
return material.GetViewModel;
|
||||
}
|
||||
|
||||
public MaterialViewModel? Delete(MaterialBindingModel model)
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
var material = context.Materials.FirstOrDefault(x => x.ID == model.ID);
|
||||
if(material == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Materials.Remove(material);
|
||||
context.SaveChanges();
|
||||
return material.GetViewModel;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
using DressAtelierContracts.BindingModels;
|
||||
using DressAtelierContracts.SearchModels;
|
||||
using DressAtelierContracts.StorageContracts;
|
||||
using DressAtelierContracts.ViewModels;
|
||||
using DressAtelierDatabaseImplementation.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DressAtelierDatabaseImplementation.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
return context.Orders.Include(x => x.Dress).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
return context.Orders.Include(x => x.Dress).Where(x => x.ID == model.ID).ToList().Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.ID.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new DressAtelierDatabase();
|
||||
return context.Orders.Include(x => x.Dress).FirstOrDefault(x => x.ID == model.ID)?.GetViewModel;
|
||||
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
var newOrder = Order.Create(model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Dress).FirstOrDefault(x => x.ID == model.ID)?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var order = context.Orders.FirstOrDefault(x => x.ID == model.ID);
|
||||
if(order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Dress).FirstOrDefault(x => x.ID == model.ID)?.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new DressAtelierDatabase();
|
||||
var order = context.Orders.FirstOrDefault(x => x.ID == model.ID);
|
||||
if(order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Orders.Remove(order);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Dress).FirstOrDefault(x => x.ID == model.ID)?.GetViewModel;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
171
DressAtelierDatabaseImplementation/Migrations/20230312193501_InitMigration.Designer.cs
generated
Normal file
171
DressAtelierDatabaseImplementation/Migrations/20230312193501_InitMigration.Designer.cs
generated
Normal file
@ -0,0 +1,171 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DressAtelierDatabaseImplementation;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DressAtelierDatabaseImplementation.Migrations
|
||||
{
|
||||
[DbContext(typeof(DressAtelierDatabase))]
|
||||
[Migration("20230312193501_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("DressAtelierDatabaseImplementation.Models.Dress", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("DressName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Dresses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.DressMaterial", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DressID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MaterialID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DressID");
|
||||
|
||||
b.HasIndex("MaterialID");
|
||||
|
||||
b.ToTable("DressMaterials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Material", 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("Materials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.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>("DressID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DressID");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.DressMaterial", b =>
|
||||
{
|
||||
b.HasOne("DressAtelierDatabaseImplementation.Models.Dress", "Dress")
|
||||
.WithMany("Materials")
|
||||
.HasForeignKey("DressID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DressAtelierDatabaseImplementation.Models.Material", "Material")
|
||||
.WithMany("DressComponents")
|
||||
.HasForeignKey("MaterialID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Dress");
|
||||
|
||||
b.Navigation("Material");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("DressAtelierDatabaseImplementation.Models.Dress", "Dress")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("DressID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Dress");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Dress", b =>
|
||||
{
|
||||
b.Navigation("Materials");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Material", b =>
|
||||
{
|
||||
b.Navigation("DressComponents");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DressAtelierDatabaseImplementation.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitMigration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Dresses",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
DressName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Dresses", x => x.ID);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Materials",
|
||||
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_Materials", x => x.ID);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
DressID = table.Column<int>(type: "int", 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_Dresses_DressID",
|
||||
column: x => x.DressID,
|
||||
principalTable: "Dresses",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "DressMaterials",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
DressID = table.Column<int>(type: "int", nullable: false),
|
||||
MaterialID = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_DressMaterials", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_DressMaterials_Dresses_DressID",
|
||||
column: x => x.DressID,
|
||||
principalTable: "Dresses",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_DressMaterials_Materials_MaterialID",
|
||||
column: x => x.MaterialID,
|
||||
principalTable: "Materials",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_DressMaterials_DressID",
|
||||
table: "DressMaterials",
|
||||
column: "DressID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_DressMaterials_MaterialID",
|
||||
table: "DressMaterials",
|
||||
column: "MaterialID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_DressID",
|
||||
table: "Orders",
|
||||
column: "DressID");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "DressMaterials");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Materials");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Dresses");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DressAtelierDatabaseImplementation;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DressAtelierDatabaseImplementation.Migrations
|
||||
{
|
||||
[DbContext(typeof(DressAtelierDatabase))]
|
||||
partial class DressAtelierDatabaseModelSnapshot : 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("DressAtelierDatabaseImplementation.Models.Dress", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("DressName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Dresses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.DressMaterial", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DressID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MaterialID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DressID");
|
||||
|
||||
b.HasIndex("MaterialID");
|
||||
|
||||
b.ToTable("DressMaterials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Material", 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("Materials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.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>("DressID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DressID");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.DressMaterial", b =>
|
||||
{
|
||||
b.HasOne("DressAtelierDatabaseImplementation.Models.Dress", "Dress")
|
||||
.WithMany("Materials")
|
||||
.HasForeignKey("DressID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DressAtelierDatabaseImplementation.Models.Material", "Material")
|
||||
.WithMany("DressComponents")
|
||||
.HasForeignKey("MaterialID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Dress");
|
||||
|
||||
b.Navigation("Material");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("DressAtelierDatabaseImplementation.Models.Dress", "Dress")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("DressID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Dress");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Dress", b =>
|
||||
{
|
||||
b.Navigation("Materials");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DressAtelierDatabaseImplementation.Models.Material", b =>
|
||||
{
|
||||
b.Navigation("DressComponents");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -38,7 +38,7 @@ namespace DressAtelierDatabaseImplementation.Models
|
||||
[ForeignKey("DressID")]
|
||||
public virtual List<DressMaterial> Materials { get; set; } = new();
|
||||
|
||||
[ForeignKey("OrderID")]
|
||||
[ForeignKey("DressID")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
|
||||
public static Dress Create(DressAtelierDatabase context, DressBindingModel model)
|
||||
|
@ -32,7 +32,6 @@ namespace DressAtelierDatabaseImplementation.Models
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
[ForeignKey("DressID")]
|
||||
public virtual Dress Dress { get; set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
|
@ -1,7 +1,7 @@
|
||||
using DressAtelierBusinessLogic.BusinessLogic;
|
||||
using DressAtelierContracts.BusinessLogicContracts;
|
||||
using DressAtelierContracts.StorageContracts;
|
||||
using DressAtelierFileImplement.Implements;
|
||||
using DressAtelierDatabaseImplementation.Implements;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
|
@ -19,7 +19,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DressAtelierFileImplement",
|
||||
{5500343A-5929-4C91-8509-D0E5F65D19BF} = {5500343A-5929-4C91-8509-D0E5F65D19BF}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DressAtelierDatabaseImplementation", "..\DressAtelierDatabaseImplementation\DressAtelierDatabaseImplementation.csproj", "{0C07823E-158E-4E02-9784-FB9705E28EE4}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DressAtelierDatabaseImplementation", "..\DressAtelierDatabaseImplementation\DressAtelierDatabaseImplementation.csproj", "{0C07823E-158E-4E02-9784-FB9705E28EE4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
Loading…
Reference in New Issue
Block a user