laatzen/LaaProductionWeb/LaaProductionWeb.Services/Models/OrderScanModel.cs
2023-05-11 15:20:12 +02:00

43 lines
1.3 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 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
=> $"~/Shipments/Pallet?ordernr={this.OrderNr}&positionnr={this.PositionNr}";
public void UpdatePallets(IEnumerable<int> pallets)
{
this.Pallets = pallets.ToDictionary(x => x, x => x == this.PalletNr);
if (this.PalletNr == 0)
{
this.PalletNr = Math.Max(this.Pallets.Keys.LastOrDefault(), 1);
}
if (!this.Pallets.ContainsKey(this.PalletNr))
{
this.Pallets[this.PalletNr] = true;
}
}
}
}