diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/CarRepairShopDatabaseImplement.csproj b/CarRepairShop/CarRepairShopDatabaseImplement/CarRepairShopDatabaseImplement.csproj
index 82f4fe9..792b545 100644
--- a/CarRepairShop/CarRepairShopDatabaseImplement/CarRepairShopDatabaseImplement.csproj
+++ b/CarRepairShop/CarRepairShopDatabaseImplement/CarRepairShopDatabaseImplement.csproj
@@ -20,8 +20,4 @@
-
-
-
-
diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Implements/OrderStorage.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Implements/OrderStorage.cs
index 15d2e6a..f6fc350 100644
--- a/CarRepairShop/CarRepairShopDatabaseImplement/Implements/OrderStorage.cs
+++ b/CarRepairShop/CarRepairShopDatabaseImplement/Implements/OrderStorage.cs
@@ -3,6 +3,7 @@ using CarRepairShopContracts.SearchModels;
using CarRepairShopContracts.StoragesContracts;
using CarRepairShopContracts.ViewModels;
using CarRepairShopDatabaseImplement.Models;
+using Microsoft.EntityFrameworkCore;
namespace CarRepairShopDatabaseImplement.Implements
{
@@ -11,7 +12,7 @@ namespace CarRepairShopDatabaseImplement.Implements
public List GetFullList()
{
using var context = new RepairsShopDatabase();
- return context.Orders
+ return context.Orders.Include(x => x.Repair)
.Select(x => x.GetViewModel)
.ToList();
}
diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240312202857_InitialCreate.Designer.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240324163100_InitialCreate.Designer.cs
similarity index 98%
rename from CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240312202857_InitialCreate.Designer.cs
rename to CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240324163100_InitialCreate.Designer.cs
index 9fe4b77..b8e7c4d 100644
--- a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240312202857_InitialCreate.Designer.cs
+++ b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240324163100_InitialCreate.Designer.cs
@@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CarRepairShopDatabaseImplement.Migrations
{
[DbContext(typeof(RepairsShopDatabase))]
- [Migration("20240312202857_InitialCreate")]
+ [Migration("20240324163100_InitialCreate")]
partial class InitialCreate
{
///
@@ -126,11 +126,13 @@ namespace CarRepairShopDatabaseImplement.Migrations
modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Order", b =>
{
- b.HasOne("CarRepairShopDatabaseImplement.Models.Repair", null)
+ b.HasOne("CarRepairShopDatabaseImplement.Models.Repair", "Repair")
.WithMany("Orders")
.HasForeignKey("RepairId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+
+ b.Navigation("Repair");
});
modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.RepairComponent", b =>
diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240312202857_InitialCreate.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240324163100_InitialCreate.cs
similarity index 100%
rename from CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240312202857_InitialCreate.cs
rename to CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240324163100_InitialCreate.cs
diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/RepairsShopDatabaseModelSnapshot.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/RepairsShopDatabaseModelSnapshot.cs
index f0531b6..e88cd6a 100644
--- a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/RepairsShopDatabaseModelSnapshot.cs
+++ b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/RepairsShopDatabaseModelSnapshot.cs
@@ -1,13 +1,17 @@
//
+using System;
+using CarRepairShopDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace CarRepairShopDatabaseImplement.Migrations
{
[DbContext(typeof(RepairsShopDatabase))]
- partial class CarRepairShopDatabaseModelSnapshot : ModelSnapshot
+ partial class RepairsShopDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
@@ -124,6 +128,7 @@ namespace CarRepairShopDatabaseImplement.Migrations
.HasForeignKey("RepairId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
+
b.Navigation("Repair");
});
diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Models/Order.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Models/Order.cs
index 6fca62a..8a0e069 100644
--- a/CarRepairShop/CarRepairShopDatabaseImplement/Models/Order.cs
+++ b/CarRepairShop/CarRepairShopDatabaseImplement/Models/Order.cs
@@ -21,7 +21,7 @@ namespace CarRepairShopDatabaseImplement.Models
public int RepairId { get; private set; }
public virtual Repair Repair { get; set; } = new();
- public static Order? Create(RepairsShopDatabase context, OrderBindingModel model)
+ public static Order? Create(OrderBindingModel model)
{
return new Order()
{
@@ -32,7 +32,6 @@ namespace CarRepairShopDatabaseImplement.Models
DateCreate = model.DateCreate,
DateImplement = model.DateImplement,
RepairId = model.RepairId,
- Repair = context.Repairs.FirstOrDefault(x => x.Id == model.RepairId)
};
}