fix
This commit is contained in:
parent
7e8fe4cf08
commit
fe31f3d034
@ -1,8 +1,10 @@
|
|||||||
using PrecastConcretePlantContracts.BindingModels;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PrecastConcretePlantContracts.BindingModels;
|
||||||
using PrecastConcretePlantContracts.ViewModels;
|
using PrecastConcretePlantContracts.ViewModels;
|
||||||
using PrecastConcretePlantDataModels.Enums;
|
using PrecastConcretePlantDataModels.Enums;
|
||||||
using PrecastConcretePlantDataModels.Models;
|
using PrecastConcretePlantDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
|
||||||
namespace PrecastConcretePlantDatabaseImplement.Models
|
namespace PrecastConcretePlantDatabaseImplement.Models
|
||||||
@ -30,6 +32,7 @@ namespace PrecastConcretePlantDatabaseImplement.Models
|
|||||||
|
|
||||||
public Reinforced Reinforced { get; private set; }
|
public Reinforced Reinforced { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -69,7 +72,7 @@ namespace PrecastConcretePlantDatabaseImplement.Models
|
|||||||
var context = new PrecastConcretePlantDatabase();
|
var context = new PrecastConcretePlantDatabase();
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
ReinforcedName = context.Reinforceds.FirstOrDefault(x => x.Id == ReinforcedId)?.ReinforcedName ?? string.Empty,
|
ReinforcedName = Reinforced?.ReinforcedName ?? string.Empty,
|
||||||
ReinforcedId = ReinforcedId,
|
ReinforcedId = ReinforcedId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using PrecastConcretePlantContracts.BindingModels;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PrecastConcretePlantContracts.BindingModels;
|
||||||
using PrecastConcretePlantContracts.SearchModels;
|
using PrecastConcretePlantContracts.SearchModels;
|
||||||
using PrecastConcretePlantContracts.StoragesContract;
|
using PrecastConcretePlantContracts.StoragesContract;
|
||||||
using PrecastConcretePlantContracts.ViewModels;
|
using PrecastConcretePlantContracts.ViewModels;
|
||||||
@ -16,7 +17,7 @@ namespace PrecastConcretePlantDatabaseImplement
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return context.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
return context.Orders.Include(x => x.Reinforced).FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
@ -29,6 +30,7 @@ namespace PrecastConcretePlantDatabaseImplement
|
|||||||
{
|
{
|
||||||
using var context = new PrecastConcretePlantDatabase();
|
using var context = new PrecastConcretePlantDatabase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
|
.Include(x => x.Reinforced)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -49,7 +51,7 @@ namespace PrecastConcretePlantDatabaseImplement
|
|||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new PrecastConcretePlantDatabase();
|
using var context = new PrecastConcretePlantDatabase();
|
||||||
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
var order = context.Orders.Include(x => x.Reinforced).FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -62,7 +64,7 @@ namespace PrecastConcretePlantDatabaseImplement
|
|||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new PrecastConcretePlantDatabase();
|
using var context = new PrecastConcretePlantDatabase();
|
||||||
var element = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
var element = context.Orders.Include(x => x.Reinforced).FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
context.Orders.Remove(element);
|
context.Orders.Remove(element);
|
||||||
|
Loading…
Reference in New Issue
Block a user