Вроде третья фулл
This commit is contained in:
parent
22eda2809c
commit
bb3f6a30f1
@ -13,7 +13,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShipyardListImplement", "Sh
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShipyardView", "ShipyardView\ShipyardView.csproj", "{BE881F13-7D8F-43B7-AA58-18BBE668FA79}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShipyardView", "ShipyardView\ShipyardView.csproj", "{BE881F13-7D8F-43B7-AA58-18BBE668FA79}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShipyardFileImplement", "ShipyardFileImplement\ShipyardFileImplement.csproj", "{804C4D1B-2098-4653-8CBA-F5931605A28D}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShipyardFileImplement", "ShipyardFileImplement\ShipyardFileImplement.csproj", "{804C4D1B-2098-4653-8CBA-F5931605A28D}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShipyardDataBaseImplement", "ShipyardDataBaseImplement\ShipyardDataBaseImplement.csproj", "{1AAB9FB9-BD51-4EF1-BC80-E17FA9B6851E}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -45,6 +47,10 @@ Global
|
|||||||
{804C4D1B-2098-4653-8CBA-F5931605A28D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{804C4D1B-2098-4653-8CBA-F5931605A28D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{804C4D1B-2098-4653-8CBA-F5931605A28D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{804C4D1B-2098-4653-8CBA-F5931605A28D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{804C4D1B-2098-4653-8CBA-F5931605A28D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{804C4D1B-2098-4653-8CBA-F5931605A28D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1AAB9FB9-BD51-4EF1-BC80-E17FA9B6851E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1AAB9FB9-BD51-4EF1-BC80-E17FA9B6851E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1AAB9FB9-BD51-4EF1-BC80-E17FA9B6851E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1AAB9FB9-BD51-4EF1-BC80-E17FA9B6851E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -0,0 +1,84 @@
|
|||||||
|
using ShipyardContracts.BindingModels;
|
||||||
|
using ShipyardContracts.SearchModels;
|
||||||
|
using ShipyardContracts.StoragesContracts;
|
||||||
|
using ShipyardContracts.ViewModels;
|
||||||
|
using ShipyardDataBaseImplement.Models;
|
||||||
|
|
||||||
|
namespace ShipyardDataBaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class DetailStorage : IDetailStorage
|
||||||
|
{
|
||||||
|
public List<DetailViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
return context.Details
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public List<DetailViewModel> GetFilteredList(DetailSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.DetailName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
return context.Details
|
||||||
|
.Where(x => x.DetailName.Contains(model.DetailName))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public DetailViewModel? GetElement(DetailSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.DetailName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
return context.Details
|
||||||
|
.FirstOrDefault(x =>
|
||||||
|
(!string.IsNullOrEmpty(model.DetailName) && x.DetailName ==
|
||||||
|
model.DetailName) ||
|
||||||
|
(model.Id.HasValue && x.Id == model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public DetailViewModel? Insert(DetailBindingModel model)
|
||||||
|
{
|
||||||
|
var newDetail = Detail.Create(model);
|
||||||
|
if (newDetail == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
context.Details.Add(newDetail);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newDetail.GetViewModel;
|
||||||
|
}
|
||||||
|
public DetailViewModel? Update(DetailBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
var detail = context.Details.FirstOrDefault(x => x.Id ==
|
||||||
|
model.Id);
|
||||||
|
if (detail == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
detail.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return detail.GetViewModel;
|
||||||
|
}
|
||||||
|
public DetailViewModel? Delete(DetailBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
var element = context.Details.FirstOrDefault(rec => rec.Id ==
|
||||||
|
model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Details.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using ShipyardContracts.BindingModels;
|
||||||
|
using ShipyardContracts.SearchModels;
|
||||||
|
using ShipyardContracts.StoragesContracts;
|
||||||
|
using ShipyardContracts.ViewModels;
|
||||||
|
using ShipyardDataBaseImplement.Models;
|
||||||
|
|
||||||
|
namespace ShipyardDataBaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class OrderStorage : IOrderStorage
|
||||||
|
{
|
||||||
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
var element = context.Orders
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
var deletedElement = context.Orders
|
||||||
|
.Include(x => x.Ship)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
context.Orders.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return deletedElement;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
return context.Orders
|
||||||
|
.Include(x => x.Ship)
|
||||||
|
.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 ShipyardDataBase();
|
||||||
|
return context.Orders
|
||||||
|
.Include(x => x.Ship)
|
||||||
|
.Where(x => x.Id == model.Id)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OrderViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
return context.Orders
|
||||||
|
.Include(x => x.Ship)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
var newOrder = Order.Create(model);
|
||||||
|
if (newOrder == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
context.Orders.Add(newOrder);
|
||||||
|
context.SaveChanges();
|
||||||
|
return context.Orders
|
||||||
|
.Include(x => x.Ship)
|
||||||
|
.FirstOrDefault(x => x.Id == newOrder.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
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.Ship)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
102
Shipyard/ShipyardDataBaseImplement/Implements/ShipStorage.cs
Normal file
102
Shipyard/ShipyardDataBaseImplement/Implements/ShipStorage.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using ShipyardContracts.BindingModels;
|
||||||
|
using ShipyardContracts.SearchModels;
|
||||||
|
using ShipyardContracts.StoragesContracts;
|
||||||
|
using ShipyardContracts.ViewModels;
|
||||||
|
using ShipyardDataBaseImplement.Models;
|
||||||
|
|
||||||
|
namespace ShipyardDataBaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ShipStorage : IShipStorage
|
||||||
|
{
|
||||||
|
public List<ShipViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
return context.Ships.Include(x => x.Details)
|
||||||
|
.ThenInclude(x => x.Detail)
|
||||||
|
.ToList()
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public List<ShipViewModel> GetFilteredList(ShipSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShipName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
return context.Ships
|
||||||
|
.Include(x => x.Details)
|
||||||
|
.ThenInclude(x => x.Detail)
|
||||||
|
.Where(x => x.ShipName.Contains(model.ShipName))
|
||||||
|
.ToList()
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public ShipViewModel? GetElement(ShipSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShipName) &&
|
||||||
|
!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
return context.Ships
|
||||||
|
.Include(x => x.Details)
|
||||||
|
.ThenInclude(x => x.Detail)
|
||||||
|
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ShipName) &&
|
||||||
|
x.ShipName == model.ShipName) ||
|
||||||
|
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
public ShipViewModel? Insert(ShipBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
var newProduct = Ship.Create(context, model);
|
||||||
|
if (newProduct == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.Ships.Add(newProduct);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newProduct.GetViewModel;
|
||||||
|
}
|
||||||
|
public ShipViewModel? Update(ShipBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var product = context.Ships.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (product == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
product.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
product.UpdateComponents(context, model);
|
||||||
|
transaction.Commit();
|
||||||
|
return product.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ShipViewModel? Delete(ShipBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new ShipyardDataBase();
|
||||||
|
var element = context.Ships
|
||||||
|
.Include(x => x.Details)
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Ships.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
171
Shipyard/ShipyardDataBaseImplement/Migrations/20240310181644_InitialCreate.Designer.cs
generated
Normal file
171
Shipyard/ShipyardDataBaseImplement/Migrations/20240310181644_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
// <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 ShipyardDataBaseImplement;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ShipyardDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ShipyardDataBase))]
|
||||||
|
[Migration("20240310181644_InitialCreate")]
|
||||||
|
partial class InitialCreate
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.16")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.Detail", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<double>("Cost")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<string>("DetailName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Details");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.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>("ShipId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ShipId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.Ship", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<string>("ShipName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Ships");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.ShipDetail", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("DetailId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ShipId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("DetailId");
|
||||||
|
|
||||||
|
b.HasIndex("ShipId");
|
||||||
|
|
||||||
|
b.ToTable("ShipDetails");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ShipyardDataBaseImplement.Models.Ship", "Ship")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ShipId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Ship");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.ShipDetail", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ShipyardDataBaseImplement.Models.Detail", "Detail")
|
||||||
|
.WithMany("ShipDetails")
|
||||||
|
.HasForeignKey("DetailId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ShipyardDataBaseImplement.Models.Ship", "Ship")
|
||||||
|
.WithMany("Details")
|
||||||
|
.HasForeignKey("ShipId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Detail");
|
||||||
|
|
||||||
|
b.Navigation("Ship");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.Detail", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("ShipDetails");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.Ship", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Details");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,125 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ShipyardDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class InitialCreate : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Details",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
DetailName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Cost = table.Column<double>(type: "float", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Details", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Ships",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ShipName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Price = table.Column<double>(type: "float", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Ships", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Orders",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ShipId = 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_Ships_ShipId",
|
||||||
|
column: x => x.ShipId,
|
||||||
|
principalTable: "Ships",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ShipDetails",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ShipId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
DetailId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Count = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ShipDetails", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ShipDetails_Details_DetailId",
|
||||||
|
column: x => x.DetailId,
|
||||||
|
principalTable: "Details",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ShipDetails_Ships_ShipId",
|
||||||
|
column: x => x.ShipId,
|
||||||
|
principalTable: "Ships",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_ShipId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ShipId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ShipDetails_DetailId",
|
||||||
|
table: "ShipDetails",
|
||||||
|
column: "DetailId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ShipDetails_ShipId",
|
||||||
|
table: "ShipDetails",
|
||||||
|
column: "ShipId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ShipDetails");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Details");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Ships");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,168 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using ShipyardDataBaseImplement;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ShipyardDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ShipyardDataBase))]
|
||||||
|
partial class ShipyardDataBaseModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.16")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.Detail", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<double>("Cost")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<string>("DetailName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Details");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.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>("ShipId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ShipId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.Ship", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<string>("ShipName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Ships");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.ShipDetail", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("DetailId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ShipId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("DetailId");
|
||||||
|
|
||||||
|
b.HasIndex("ShipId");
|
||||||
|
|
||||||
|
b.ToTable("ShipDetails");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ShipyardDataBaseImplement.Models.Ship", "Ship")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ShipId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Ship");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.ShipDetail", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ShipyardDataBaseImplement.Models.Detail", "Detail")
|
||||||
|
.WithMany("ShipDetails")
|
||||||
|
.HasForeignKey("DetailId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ShipyardDataBaseImplement.Models.Ship", "Ship")
|
||||||
|
.WithMany("Details")
|
||||||
|
.HasForeignKey("ShipId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Detail");
|
||||||
|
|
||||||
|
b.Navigation("Ship");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.Detail", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("ShipDetails");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ShipyardDataBaseImplement.Models.Ship", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Details");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
57
Shipyard/ShipyardDataBaseImplement/Models/Detail.cs
Normal file
57
Shipyard/ShipyardDataBaseImplement/Models/Detail.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using ShipyardContracts.BindingModels;
|
||||||
|
using ShipyardContracts.ViewModels;
|
||||||
|
using ShipyardDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace ShipyardDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Detail : IDetailModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
[Required]
|
||||||
|
public string DetailName { get; private set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public double Cost { get; set; }
|
||||||
|
[ForeignKey("DetailId")]
|
||||||
|
public virtual List<ShipDetail> ShipDetails { get; set; } = new();
|
||||||
|
public static Detail? Create(DetailBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Detail()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
DetailName = model.DetailName,
|
||||||
|
Cost = model.Cost
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static Detail Create(DetailViewModel model)
|
||||||
|
{
|
||||||
|
return new Detail
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
DetailName = model.DetailName,
|
||||||
|
Cost = model.Cost
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(DetailBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DetailName = model.DetailName;
|
||||||
|
Cost = model.Cost;
|
||||||
|
}
|
||||||
|
public DetailViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
DetailName = DetailName,
|
||||||
|
Cost = Cost
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
64
Shipyard/ShipyardDataBaseImplement/Models/Order.cs
Normal file
64
Shipyard/ShipyardDataBaseImplement/Models/Order.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using ShipyardContracts.BindingModels;
|
||||||
|
using ShipyardContracts.ViewModels;
|
||||||
|
using ShipyardDataModels.Enums;
|
||||||
|
using ShipyardDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace ShipyardDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Order : IOrderModel
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public int ShipId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int Count { get; set; }
|
||||||
|
[Required]
|
||||||
|
public double Sum { get; set; }
|
||||||
|
[Required]
|
||||||
|
public OrderStatus Status { get; set; }
|
||||||
|
[Required]
|
||||||
|
public DateTime DateCreate { get; set; }
|
||||||
|
public DateTime? DateImplement { get; set; }
|
||||||
|
public int Id { get; set; }
|
||||||
|
public virtual Ship Ship { get; set; }
|
||||||
|
public static Order? Create(OrderBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Order()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ShipId = model.ShipId,
|
||||||
|
Count = model.Count,
|
||||||
|
Sum = model.Sum,
|
||||||
|
Status = model.Status,
|
||||||
|
DateCreate = model.DateCreate,
|
||||||
|
DateImplement = model.DateImplement
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(OrderBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Status = model.Status;
|
||||||
|
DateImplement = model.DateImplement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShipId = ShipId,
|
||||||
|
Count = Count,
|
||||||
|
Sum = Sum,
|
||||||
|
Status = Status,
|
||||||
|
DateCreate = DateCreate,
|
||||||
|
DateImplement = DateImplement,
|
||||||
|
ShipName = Ship.ShipName
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
90
Shipyard/ShipyardDataBaseImplement/Models/Ship.cs
Normal file
90
Shipyard/ShipyardDataBaseImplement/Models/Ship.cs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
using ShipyardContracts.BindingModels;
|
||||||
|
using ShipyardContracts.ViewModels;
|
||||||
|
using ShipyardDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace ShipyardDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Ship : IShipModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string ShipName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public double Price { get; set; }
|
||||||
|
private Dictionary<int, (IDetailModel, int)>? _shipDetails = null;
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, (IDetailModel, int)> ShipDetails
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_shipDetails == null)
|
||||||
|
{
|
||||||
|
_shipDetails = Details.ToDictionary(recPC => recPC.DetailId, recPC =>
|
||||||
|
(recPC.Detail as IDetailModel, recPC.Count));
|
||||||
|
}
|
||||||
|
return _shipDetails;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[ForeignKey("ShipId")]
|
||||||
|
public virtual List<ShipDetail> Details { get; set; } = new();
|
||||||
|
[ForeignKey("ShipId")]
|
||||||
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
|
public static Ship Create(ShipyardDataBase context, ShipBindingModel model)
|
||||||
|
{
|
||||||
|
return new Ship()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ShipName = model.ShipName,
|
||||||
|
Price = model.Price,
|
||||||
|
Details = model.ShipDetails.Select(x => new ShipDetail
|
||||||
|
{
|
||||||
|
Detail = context.Details.First(y => y.Id == x.Key),
|
||||||
|
Count = x.Value.Item2
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ShipBindingModel model)
|
||||||
|
{
|
||||||
|
ShipName = model.ShipName;
|
||||||
|
Price = model.Price;
|
||||||
|
}
|
||||||
|
public ShipViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShipName = ShipName,
|
||||||
|
Price = Price,
|
||||||
|
ShipDetails = ShipDetails
|
||||||
|
};
|
||||||
|
public void UpdateComponents(ShipyardDataBase context,
|
||||||
|
ShipBindingModel model)
|
||||||
|
{
|
||||||
|
var shipDetails = context.ShipDetails.Where(rec => rec.ShipId == model.Id).ToList();
|
||||||
|
if (shipDetails != null && shipDetails.Count > 0)
|
||||||
|
{ // удалили те, которых нет в модели
|
||||||
|
context.ShipDetails.RemoveRange(shipDetails.Where(rec => !model.ShipDetails.ContainsKey(rec.DetailId)));
|
||||||
|
context.SaveChanges();
|
||||||
|
// обновили количество у существующих записей
|
||||||
|
foreach (var updateDetail in shipDetails)
|
||||||
|
{
|
||||||
|
updateDetail.Count = model.ShipDetails[updateDetail.DetailId].Item2;
|
||||||
|
model.ShipDetails.Remove(updateDetail.DetailId);
|
||||||
|
}
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
var ship = context.Ships.First(x => x.Id == Id);
|
||||||
|
foreach (var pc in model.ShipDetails)
|
||||||
|
{
|
||||||
|
context.ShipDetails.Add(new ShipDetail
|
||||||
|
{
|
||||||
|
Ship = ship,
|
||||||
|
Detail = context.Details.First(x => x.Id == pc.Key),
|
||||||
|
Count = pc.Value.Item2
|
||||||
|
});
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
_shipDetails = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
Shipyard/ShipyardDataBaseImplement/Models/ShipDetail.cs
Normal file
18
Shipyard/ShipyardDataBaseImplement/Models/ShipDetail.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace ShipyardDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class ShipDetail
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int ShipId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int DetailId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int Count { get; set; }
|
||||||
|
public virtual Detail Detail { get; set; } = new();
|
||||||
|
public virtual Ship Ship { get; set; } = new();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
22
Shipyard/ShipyardDataBaseImplement/ShipyardDataBase.cs
Normal file
22
Shipyard/ShipyardDataBaseImplement/ShipyardDataBase.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using ShipyardDataBaseImplement.Models;
|
||||||
|
|
||||||
|
namespace ShipyardDataBaseImplement
|
||||||
|
{
|
||||||
|
public class ShipyardDataBase : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
if (optionsBuilder.IsConfigured == false)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-JJTVLCG\SQLEXPRESS02;Initial Catalog=ShipyardDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
|
}
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
}
|
||||||
|
public virtual DbSet<Detail> Details { set; get; }
|
||||||
|
public virtual DbSet<Ship> Ships { set; get; }
|
||||||
|
public virtual DbSet<ShipDetail> ShipDetails { set; get; }
|
||||||
|
public virtual DbSet<Order> Orders { set; get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.16" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.16" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.16">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\ShipyardContracts\ShipyardContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\ShipyardDataModels\ShipyardDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
2
Shipyard/ShipyardView/FormMain.Designer.cs
generated
2
Shipyard/ShipyardView/FormMain.Designer.cs
generated
@ -156,7 +156,7 @@
|
|||||||
Controls.Add(dataGridView);
|
Controls.Add(dataGridView);
|
||||||
Controls.Add(toolStrip);
|
Controls.Add(toolStrip);
|
||||||
Name = "FormMain";
|
Name = "FormMain";
|
||||||
Text = "FormMain";
|
Text = "Форма заказов";
|
||||||
Load += FormMain_Load;
|
Load += FormMain_Load;
|
||||||
toolStrip.ResumeLayout(false);
|
toolStrip.ResumeLayout(false);
|
||||||
toolStrip.PerformLayout();
|
toolStrip.PerformLayout();
|
||||||
|
@ -2,7 +2,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using ShipyardBusinessLogic.BusinessLogics;
|
using ShipyardBusinessLogic.BusinessLogics;
|
||||||
using ShipyardContracts.BusinessLogicsContracts;
|
using ShipyardContracts.BusinessLogicsContracts;
|
||||||
using ShipyardContracts.StoragesContracts;
|
using ShipyardContracts.StoragesContracts;
|
||||||
using ShipyardFileImplement.Implements;
|
using ShipyardDataBaseImplement.Implements;
|
||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
|
|
||||||
namespace ShipyardView
|
namespace ShipyardView
|
||||||
|
@ -13,12 +13,16 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.16">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\ShipyardBusinessLogic\ShipyardBusinessLogic.csproj" />
|
<ProjectReference Include="..\ShipyardBusinessLogic\ShipyardBusinessLogic.csproj" />
|
||||||
<ProjectReference Include="..\ShipyardFileImplement\ShipyardFileImplement.csproj" />
|
<ProjectReference Include="..\ShipyardDataBaseImplement\ShipyardDataBaseImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user