using System; using System.Collections.Generic; using System.Linq; using Gebhardt.StoreWare.Wcs.Common.DbAccess.Model; using Gebhardt.StoreWare.Wcs.Common.DbAccess.Model.Enums; namespace Gebhardt.StoreWare.Wcs.ConveyorDispo { internal record OrderListItem(int OrdersHostId, TransportOrderStatus Status, Le Le, string Destination, int Priority, int? IdOrderWmsHead, DateTime Created, string HostDestination, bool? DepartureFlag, string? DepartureLocation); internal class OrderList : List { public OrderList(List items) : base(items) { } /// /// Removes all order list items with the same LeNo and a higher list index. /// /// public void RemoveSubsequentWithEqualLeNo(OrderListItem item) { if (item is {Le: { }}) { RemoveAll(i => IndexOf(i) > IndexOf(item) && i.Le.LeNo == item.Le.LeNo); } } /// /// Removes all order list items with the same destination and a higher list index. /// /// public void RemoveSubsequentWithEqualDestination(OrderListItem item) { if (item != null) { RemoveAll(i => IndexOf(i) > IndexOf(item) && i.Destination == item.Destination); } } /// /// Removes all order list items with the same aisle name / storage area and a higher list index. /// /// public void RemoveSubsequentWithEqualAisle(OrderListItem item) { if (item?.Le?.StorageArea != null && item?.Le?.AisleName != null) { RemoveAll(i => IndexOf(i) > IndexOf(item) && i.Le.StorageArea == item.Le.StorageArea && i.Le.AisleName == item.Le.AisleName); } } /// /// Removes all order list items with a higher list index that have the same LeNo but lower priority. /// /// public void RemoveSubsequentWithEqualLeNoButLowerPriority(OrderListItem item) { if (item is {Le: { }}) { RemoveAll(i => IndexOf(i) > IndexOf(item) && i.Le.LeNo == item.Le.LeNo && i.Priority < item.Priority); } } } }