53 lines
1.7 KiB
C#
53 lines
1.7 KiB
C#
namespace LaaProductionWeb.Services.Models
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
|
|
public class OrderScanModel : OrderModel
|
|
{
|
|
public string Host { get; set; }
|
|
|
|
public string Place { get; set; }
|
|
|
|
public int PalletsCount { get; set; }
|
|
|
|
[Display(Name = "Paletten-Nr.")]
|
|
public int? PalletNr { get; set; }
|
|
|
|
public IEnumerable<int> Positions { get; set; }
|
|
= Array.Empty<int>();
|
|
|
|
public IDictionary<int, bool> Pallets { get; set; }
|
|
= new Dictionary<int, bool> { { 1, false } };
|
|
|
|
public string PrintUrl
|
|
=> $"~/Shipments/Print?ordernr={this.OrderNr}&positionnr={this.PositionNr}&palletnr={this.PalletNr}";
|
|
|
|
public string PalletUrl(int? palletNr)
|
|
=> $"~/Shipments/Pallet?ordernr={this.OrderNr}&positionnr={this.PositionNr}&palletnr={palletNr}";
|
|
|
|
internal void UpdatePallets(IEnumerable<KeyValuePair<int, bool>> pallets)
|
|
{
|
|
this.Pallets = pallets.ToDictionary(x => x.Key, x => x.Value);
|
|
|
|
if (this.PalletNr is null || this.PalletNr == 0)
|
|
{
|
|
if (pallets.Any(x => x.Value))
|
|
{
|
|
this.PalletNr = Math.Max(pallets
|
|
.Where(x => x.Value)
|
|
.OrderByDescending(x => x.Key)
|
|
.FirstOrDefault().Key, 1);
|
|
}
|
|
else
|
|
{
|
|
this.PalletNr = Math.Max(pallets
|
|
.OrderByDescending(x => x.Key)
|
|
.FirstOrDefault().Key, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |