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 Pallets { get; set; } = new Dictionary { { 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 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; } } } }