demo_trade/Domain/OrderManagerUseCase.cs
2024-10-04 15:41:04 +03:00

45 lines
1.5 KiB
C#

using demo_trade.Data.Repository;
using demo_trade.Models;
using demo_trade.UI.Presenters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace demo_trade.Domain
{
public class OrderManagerUseCase
{
private IOrderManagerRepository _orderRepository;
public OrderManagerUseCase(IOrderManagerRepository orderRepository) {
_orderRepository = orderRepository;
}
public void ChangeOrders(List<OrderChanged> orderChangeds) {
_orderRepository.EditRangeOrders(orderChangeds);
}
public List<OrderManager> GetOrders()
{
return _orderRepository.GetAllOrders().Select(it => new OrderManager {
OrderClient = it.ClientName,
Orderdeliverydate = it.Orderdeliverydate,
Orderid = it.Orderid,
Orderstatus = it.Orderstatus,
PickupPointName = it.OrderpickuppointNavigation.PickupPointName,
ProductList = String.Join("\n", it.Orderproducts.Select(product => String.Format("Article: {0} Count: {1} Stock: {2}",
product.Productarticlenumber,
product.ProductCount,
product.ProductarticlenumberNavigation.Productquantityinstock
)).ToList()),
OrderSumCost = it.OrderSumCost,
ProductStock = it.Orderproducts.Select(it => it.ProductarticlenumberNavigation).ToList()
}).ToList();
}
}
}