Shipments bug fix
This commit is contained in:
@@ -14,7 +14,10 @@
|
||||
public int PalletsCount { get; set; }
|
||||
|
||||
[Display(Name = "Paletten-Nr.")]
|
||||
public int PalletNr { get; set; }
|
||||
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 } };
|
||||
@@ -22,21 +25,28 @@
|
||||
public string PrintUrl
|
||||
=> $"~/Shipments/Print?ordernr={this.OrderNr}&positionnr={this.PositionNr}&palletnr={this.PalletNr}";
|
||||
|
||||
public string PalletUrl
|
||||
=> $"~/Shipments/Pallet?ordernr={this.OrderNr}&positionnr={this.PositionNr}";
|
||||
public string PalletUrl(int? palletNr)
|
||||
=> $"~/Shipments/Pallet?ordernr={this.OrderNr}&positionnr={this.PositionNr}&palletnr={palletNr}";
|
||||
|
||||
public void UpdatePallets(IEnumerable<int> pallets)
|
||||
internal void UpdatePallets(IEnumerable<KeyValuePair<int, bool>> pallets)
|
||||
{
|
||||
this.Pallets = pallets.ToDictionary(x => x, x => x == this.PalletNr);
|
||||
this.Pallets = pallets.ToDictionary(x => x.Key, x => x.Value);
|
||||
|
||||
if (this.PalletNr == 0)
|
||||
if (this.PalletNr is null || this.PalletNr == 0)
|
||||
{
|
||||
this.PalletNr = Math.Max(this.Pallets.Keys.LastOrDefault(), 1);
|
||||
}
|
||||
|
||||
if (!this.Pallets.ContainsKey(this.PalletNr))
|
||||
{
|
||||
this.Pallets[this.PalletNr] = true;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user