temp entity added
This commit is contained in:
parent
6b3e4b8f45
commit
496d4a0f77
@ -24,11 +24,26 @@ namespace ProjectPublishing.Entities
|
||||
|
||||
public int PrintingId { get; private set; }
|
||||
|
||||
public List<OrderMaterials> Materials { get; private set; }
|
||||
public IEnumerable<OrderMaterials> Materials { get; private set; } = [];
|
||||
|
||||
public static Order CreateOrder(int id, string description, ProductType productType, int amount, OrderStatus status, int customerId, int printingId, List<OrderMaterials> materials)
|
||||
public static Order CreateOrder(int id, string description, ProductType productType, int amount, OrderStatus status, int customerId, int printingId, IEnumerable<OrderMaterials> materials)
|
||||
{
|
||||
return new Order { ProductType = productType, Id = id, Amount = amount, Status = status, CustomerId = customerId, PrintingId = printingId, Materials = materials, OrderDate = DateTime.Now, Description = description ?? string.Empty };
|
||||
}
|
||||
|
||||
public static Order CreateOrder(TempOrderMaterials tempOrderMaterials, IEnumerable<OrderMaterials> materials)
|
||||
{
|
||||
return new Order
|
||||
{
|
||||
ProductType = tempOrderMaterials.ProductType,
|
||||
Id = tempOrderMaterials.Id,
|
||||
Amount = tempOrderMaterials.Amount,
|
||||
Status = tempOrderMaterials.Status,
|
||||
CustomerId = tempOrderMaterials.CustomerId,
|
||||
PrintingId = tempOrderMaterials.PrintingId,
|
||||
Materials = materials,
|
||||
OrderDate = DateTime.Now,
|
||||
Description = tempOrderMaterials.Description ?? string.Empty };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
using ProjectPublishing.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectPublishing.Entities
|
||||
{
|
||||
public class TempOrderMaterials
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public DateTime OrderDate { get; private set; }
|
||||
|
||||
public string Description { get; private set; }
|
||||
|
||||
public ProductType ProductType { get; private set; }
|
||||
|
||||
public int Amount { get; private set; }
|
||||
|
||||
public OrderStatus Status { get; private set; }
|
||||
|
||||
public int CustomerId { get; private set; }
|
||||
|
||||
public int PrintingId { get; private set; }
|
||||
|
||||
public int MaterialsId { get; private set; }
|
||||
|
||||
public int MaterialsAmount { get; private set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using ProjectPublishing.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -63,7 +64,7 @@ namespace ProjectPublishing.Reports
|
||||
CountOut = (int?)m.Amount
|
||||
})))
|
||||
.OrderBy(x => x.Date);
|
||||
|
||||
_logger.LogDebug("Объединенные данные в отчет: {json}", JsonConvert.SerializeObject(data));
|
||||
return new List<string[]> { item }
|
||||
.Union(
|
||||
data.Select(x => new string[] {
|
||||
|
@ -86,10 +86,16 @@ WHERE Id=@id";
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM PrintingOrder"; // возможно сюда фикс
|
||||
var printingOrders = connection.Query<Order>(querySelect);
|
||||
var querySelect = @"
|
||||
SELECT o.*, ma.MaterialId
|
||||
FROM PrintingOrder o
|
||||
LEFT JOIN OrderMaterials ma ON o.Id = ma.OrderId
|
||||
"; // возможно сюда фикс
|
||||
var printingOrders = connection.Query<TempOrderMaterials>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(printingOrders));
|
||||
return printingOrders;
|
||||
|
||||
return printingOrders.GroupBy(x => x.Id, y => y, (key, value) =>
|
||||
Order.CreateOrder(value.First(), value.Select(z => OrderMaterials.Create(0, z.MaterialsId, z.MaterialsAmount)))).ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user