Merge branch 'LabWork04' of https://git.is.ulstu.ru/ekallin/PIbd-21_Bakalskaya_E.D._SushiBar into LabWork04
This commit is contained in:
commit
8ffd918013
@ -7,9 +7,10 @@ using SushiBarBusinessLogic.OfficePackage;
|
||||
using SushiBarBusinessLogic.OfficePackage.Implements;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.StoragesContracts;
|
||||
using SushiBarDatabaseImplement.Implements;
|
||||
using SushiBarFileImplement.Implements;
|
||||
using SushiBarView;
|
||||
using SushiBarView.Reports;
|
||||
using System.Text;
|
||||
|
||||
namespace SushiBar
|
||||
{
|
||||
@ -29,6 +30,9 @@ namespace SushiBar
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
// Добавлено для устранения ошибки с кодировкой при сохранении в PDF
|
||||
// чтобы заработало нужно поставить NuGet пакет System.Text.Encoding.CodePages
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
|
@ -20,6 +20,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.19" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,8 +1,8 @@
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
using SushiBarBusinessLogic.OfficePackage.HelperEnums;
|
||||
using SushiBarBusinessLogic.OfficePackage.HelperModels;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
|
||||
namespace SushiBarBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
@ -89,28 +89,12 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
||||
|
||||
protected override void SavePdf(PdfInfo info)
|
||||
{
|
||||
if (_document != null)
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
|
||||
Document = _document
|
||||
};
|
||||
if (renderer.PdfDocument != null)
|
||||
{
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NullReferenceException("renderer.RenderDocument is null");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NullReferenceException("_document is null");
|
||||
}
|
||||
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,15 +17,24 @@ namespace SushiBarDatabaseImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.DateTo.HasValue && !model.DateFrom.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new SushiBarDatabase();
|
||||
using var context = new SecuritySystemDatabase();
|
||||
var orders = context.Orders
|
||||
.Include(x => x.Secure)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
if (model.Id.HasValue)
|
||||
return context.Orders.Where(x => x.Id == model.Id).Select(x => AccessViewModel(x.GetViewModel)).ToList();
|
||||
else
|
||||
return context.Orders.Where(x => x.DateCreate >= model.DateFrom).Where(x => x.DateCreate <= model.DateTo).Select(x => AccessViewModel(x.GetViewModel)).ToList();
|
||||
{
|
||||
orders = orders.Where(x => x.Id == model.Id.Value).ToList();
|
||||
}
|
||||
if (model.DateFrom.HasValue)
|
||||
{
|
||||
orders = orders.Where(x => x.DateCreate >= model.DateFrom.Value).ToList();
|
||||
}
|
||||
if (model.DateTo.HasValue)
|
||||
{
|
||||
orders = orders.Where(x => x.DateCreate <= model.DateTo.Value).ToList();
|
||||
}
|
||||
return orders;
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
|
@ -20,11 +20,22 @@ namespace SushiBarFileImplement.Implements
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
var orders = source.Orders
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
orders = orders.Where(x => x.Id == model.Id.Value).ToList();
|
||||
}
|
||||
return source.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList();
|
||||
if (model.DateFrom.HasValue)
|
||||
{
|
||||
orders = orders.Where(x => x.DateCreate >= model.DateFrom.Value).ToList();
|
||||
}
|
||||
if (model.DateTo.HasValue)
|
||||
{
|
||||
orders = orders.Where(x => x.DateCreate <= model.DateTo.Value).ToList();
|
||||
}
|
||||
return orders;
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
|
@ -28,19 +28,22 @@ namespace SushiBarListImplements.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
var result = new List<OrderViewModel>();
|
||||
if (model == null || !model.Id.HasValue)
|
||||
var orders = _source.Orders
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return result;
|
||||
orders = orders.Where(x => x.Id == model.Id.Value).ToList();
|
||||
}
|
||||
foreach (var order in _source.Orders)
|
||||
if (model.DateFrom.HasValue)
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
{
|
||||
result.Add(order.GetViewModel);
|
||||
}
|
||||
orders = orders.Where(x => x.DateCreate >= model.DateFrom.Value).ToList();
|
||||
}
|
||||
return result;
|
||||
if (model.DateTo.HasValue)
|
||||
{
|
||||
orders = orders.Where(x => x.DateCreate <= model.DateTo.Value).ToList();
|
||||
}
|
||||
return orders;
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
|
Loading…
Reference in New Issue
Block a user