Correct2
This commit is contained in:
parent
fc20462d0a
commit
818f6791d9
@ -20,8 +20,4 @@
|
||||
<ProjectReference Include="..\CarRepairShopDataModels\CarRepairShopDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -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<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new RepairsShopDatabase();
|
||||
return context.Orders
|
||||
return context.Orders.Include(x => x.Repair)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace CarRepairShopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(RepairsShopDatabase))]
|
||||
[Migration("20240312202857_InitialCreate")]
|
||||
[Migration("20240324163100_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -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 =>
|
@ -1,13 +1,17 @@
|
||||
// <auto-generated />
|
||||
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");
|
||||
});
|
||||
|
||||
|
@ -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)
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user