troubles with names
This commit is contained in:
parent
26787687f4
commit
e10908f2ee
@ -63,5 +63,15 @@ namespace ProjectPublishing.Entities
|
|||||||
OrderDate = DateTime.Now,
|
OrderDate = DateTime.Now,
|
||||||
Description = tempOrderMaterials.Description ?? string.Empty };
|
Description = tempOrderMaterials.Description ?? string.Empty };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetOrderMaterials(IEnumerable<OrderMaterials> orderMaterials)
|
||||||
|
{
|
||||||
|
if (orderMaterials != null && orderMaterials.Any())
|
||||||
|
{
|
||||||
|
Materials = orderMaterials;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
|
||||||
namespace ProjectPublishing.Repositories.Implementations
|
namespace ProjectPublishing.Repositories.Implementations
|
||||||
{
|
{
|
||||||
@ -89,8 +90,8 @@ WHERE Id=@id";
|
|||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = @"
|
||||||
SELECT o.*,
|
SELECT o.*,
|
||||||
ma.MaterialId as MaterialsId,
|
|
||||||
ma.Amount as MaterialsAmount,
|
ma.Amount as MaterialsAmount,
|
||||||
|
ma.MaterialId as MaterialsId,
|
||||||
CONCAT(c.LastName, ' ', c.FirstName) as CustomerName,
|
CONCAT(c.LastName, ' ', c.FirstName) as CustomerName,
|
||||||
ph.Name as PrintingName
|
ph.Name as PrintingName
|
||||||
FROM PrintingOrder o
|
FROM PrintingOrder o
|
||||||
@ -98,11 +99,28 @@ LEFT JOIN OrderMaterials ma ON o.Id = ma.OrderId
|
|||||||
LEFT JOIN Customer c ON o.CustomerId = c.Id
|
LEFT JOIN Customer c ON o.CustomerId = c.Id
|
||||||
LEFT JOIN PrintingHouse ph ON o.PrintingId = ph.Id
|
LEFT JOIN PrintingHouse ph ON o.PrintingId = ph.Id
|
||||||
"; // возможно сюда фикс
|
"; // возможно сюда фикс
|
||||||
var printingOrders = connection.Query<TempOrderMaterials>(querySelect);
|
//var printingOrders = connection.Query<TempOrderMaterials>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(printingOrders));
|
var ordersDict = new Dictionary<int, List<OrderMaterials>>();
|
||||||
|
var orders = connection.Query<Order, OrderMaterials, Order>(querySelect,
|
||||||
|
(order, orderMaterials) =>
|
||||||
|
{
|
||||||
|
if (!ordersDict.TryGetValue(order.Id, out var frr))
|
||||||
|
{
|
||||||
|
frr = [];
|
||||||
|
ordersDict.Add(order.Id,frr);
|
||||||
|
}
|
||||||
|
|
||||||
return printingOrders.GroupBy(x => x.Id, y => y, (key, value) =>
|
frr.Add(orderMaterials);
|
||||||
Order.CreateOrder(value.First(), value.Select(z => OrderMaterials.Create(0, z.MaterialsId, z.MaterialsAmount)))).ToList();
|
return order;
|
||||||
|
}, splitOn: "MaterialsId");
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(orders));
|
||||||
|
|
||||||
|
return ordersDict.Select(x =>
|
||||||
|
{
|
||||||
|
var o = orders.First(y => y.Id == x.Key);
|
||||||
|
o.SetOrderMaterials(x.Value);
|
||||||
|
return o;
|
||||||
|
}).ToArray();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
BIN
Отчеты/otp-doc.docx
Normal file
BIN
Отчеты/otp-doc.docx
Normal file
Binary file not shown.
BIN
Отчеты/otp-pdf.pdf
Normal file
BIN
Отчеты/otp-pdf.pdf
Normal file
Binary file not shown.
BIN
Отчеты/otp-tab.xlsx
Normal file
BIN
Отчеты/otp-tab.xlsx
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user