PIbd-23 Dyakonov R R Hard Lab work 3 #8
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace SoftwareInstallationDatabaseImplement.Implements
|
||||
{
|
||||
@ -51,14 +52,14 @@ namespace SoftwareInstallationDatabaseImplement.Implements
|
||||
|
||||
using var context = new SoftwareInstallationDatabase();
|
||||
|
||||
return context.Orders.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
return context.Orders.Include(x => x.Package).Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new SoftwareInstallationDatabase();
|
||||
|
||||
return context.Orders.Select(x => x.GetViewModel).Select(x => GetPackageName(x)).ToList();
|
||||
return context.Orders.Include(x => x.Package).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
|
@ -66,6 +66,7 @@ namespace SoftwareInstallationDatabaseImplement.Models
|
||||
{
|
||||
Id = Id,
|
||||
PackageId = PackageId,
|
||||
PackageName = Package.PackageName,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
|
@ -92,12 +92,10 @@ namespace SoftwareInstallationFileImplement.Implements
|
||||
}
|
||||
private OrderViewModel GetPackageName(OrderViewModel viewModel)
|
||||
{
|
||||
foreach (var package in source.Packages)
|
||||
var package = source.Packages.FirstOrDefault(x => x.Id == viewModel.PackageId);
|
||||
if (package != null)
|
||||
{
|
||||
if (package.Id == viewModel.PackageId)
|
||||
{
|
||||
viewModel.PackageName = package.PackageName;
|
||||
}
|
||||
viewModel.PackageName = package.PackageName;
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user