using System; using System.Linq; using Comal.Classes; using InABox.Mobile; using Syncfusion.XForms.Core; using Xamarin.CommunityToolkit.ObjectModel; using Xamarin.Forms; namespace PRS.Mobile { public class StockHoldingShell : Shell { public StockHoldingShell() { Transactions = new ObservableRangeCollection(); Transactions.CollectionChanged += (sender, args) => { OnPropertyChanged(nameof(Transactions)); }; } protected override void ConfigureColumns(ShellColumns columns) { columns .Map(nameof(ProductID), x => x.Product.ID) .Map(nameof(ProductCode), x => x.Product.Code) .Map(nameof(ProductName), x => x.Product.Name) .Map(nameof(JobID), x => x.Job.ID) .Map(nameof(JobNumber), x => x.Job.JobNumber) .Map(nameof(JobName), x => x.Job.Name) .Map(nameof(LocationID), x => x.Location.ID) .Map(nameof(LocationCode), x => x.Location.Code) .Map(nameof(LocationDescription), x => x.Location.Description) .Map(nameof(LocationAreaID), x => x.Location.Area.ID) .Map(nameof(LocationAreaCode), x => x.Location.Area.Code) .Map(nameof(LocationAreaDescription), x => x.Location.Area.Description) .Map(nameof(StyleID), x => x.Style.ID) .Map(nameof(StyleCode), x => x.Style.Code) .Map(nameof(StyleDescription), x => x.Style.Description) .Map(nameof(DimensionsUnitID), x => x.Dimensions.Unit.ID) .Map(nameof(DimensionsHasQuantity), x => x.Dimensions.Unit.HasQuantity) .Map(nameof(DimensionsHasLength), x => x.Dimensions.Unit.HasLength) .Map(nameof(DimensionsHasHeight), x => x.Dimensions.Unit.HasHeight) .Map(nameof(DimensionsHasWeight), x => x.Dimensions.Unit.HasWeight) .Map(nameof(DimensionsHasWidth), x => x.Dimensions.Unit.HasWidth) .Map(nameof(DimensionsQuantity), x => x.Dimensions.Quantity) .Map(nameof(DimensionsLength), x => x.Dimensions.Length) .Map(nameof(DimensionsHeight), x => x.Dimensions.Height) .Map(nameof(DimensionsWeight), x => x.Dimensions.Weight) .Map(nameof(DimensionsWidth), x => x.Dimensions.Width) .Map(nameof(DimensionsUnitFormat), x => x.Dimensions.Unit.Format) .Map(nameof(DimensionsUnitFormula), x => x.Dimensions.Unit.Formula) .Map(nameof(DimensionsUnitSize), x => x.Dimensions.UnitSize) .Map(nameof(DimensionsValue), x => x.Dimensions.Value) .Map(nameof(ImageID), x => x.Product.Image.ID) .Map(nameof(Units), x => x.Units) .Map(nameof(Available), x => x.Available) .Map(nameof(AverageCost), x=>x.AverageValue) .Map(nameof(LastStocktake), x=>x.LastStockTake) ; } public Guid ProductID { get => Get(); set => Set(value); } public String ProductCode { get => Get(); set => Set(value); } public String ProductName { get => Get(); set => Set(value); } public String ProductDisplay => ProductID == Guid.Empty ? "" : $"{ProductCode}: {ProductName}"; public Guid JobID { get => Get(); set { Set(value); Parent?.UpdateShells(new StockHoldingShell[] { this }); } } public String JobNumber { get => Get(); set => Set(value); } public String JobName { get => Get(); set => Set(value); } public String JobDisplay => JobID == Guid.Empty ? "" : $"{JobNumber}: {JobName}"; public Guid LocationID { get => Get(); set { Set(value); Parent?.UpdateShells(new StockHoldingShell[] { this }); } } public String LocationCode { get => Get(); set => Set(value); } public String LocationDescription { get => Get(); set => Set(value); } public Guid LocationAreaID { get => Get(); set => Set(value); } public String LocationAreaCode { get => Get(); set => Set(value); } public String LocationAreaDescription { get => Get(); set => Set(value); } public Guid StyleID { get => Get(); set { Set(value); Parent?.UpdateShells(new StockHoldingShell[] { this }); } } public String StyleCode { get => Get(); set => Set(value); } public String StyleDescription { get => Get(); set => Set(value); } public String StyleDisplay => StyleID == Guid.Empty ? "" : $"{StyleCode}: {StyleDescription}"; public Guid DimensionsUnitID { get => Get(); set => Set(value); } public string DimensionsUnitCode { get => Get(); set => Set(value); } public string DimensionsUnitDescription { get => Get(); set => Set(value); } public bool DimensionsHasQuantity { get => Get(); set => Set(value); } public double DimensionsQuantity { get => Get(); set => Set(value); } public bool DimensionsHasLength { get => Get(); set => Set(value); } public double DimensionsLength { get => Get(); set => Set(value); } public bool DimensionsHasWidth { get => Get(); set => Set(value); } public double DimensionsWidth { get => Get(); set => Set(value); } public bool DimensionsHasHeight { get => Get(); set => Set(value); } public double DimensionsHeight { get => Get(); set => Set(value); } public bool DimensionsHasWeight { get => Get(); set => Set(value); } public double DimensionsWeight { get => Get(); set => Set(value); } public double DimensionsValue { get => Get(); set => Set(value); } public string DimensionsUnitFormula { get => Get(); set => Set(value); } public string DimensionsUnitFormat { get => Get(); set => Set(value); } public string DimensionsUnitSize { get => Get(); set { Set(value); Parent?.UpdateShells(new StockHoldingShell[] { this }); } } public Guid ImageID { get => Get(); set { Set(value); OnPropertyChanged(nameof(Image)); } } public byte[]? Image { get { if (Parent != null && Parent.Images.TryGetValue(ImageID, out byte[] data)) return data; return new byte[] { }; } } public double Units { get => Get(); set => Set(value); } public double Available { get => Get(); set => Set(value); } public double AverageCost { get => Get(); set => Set(value); } public DateTime LastStocktake { get => Get(); } public ObservableRangeCollection Transactions { get; private set; } public StockTransactionAllocation[] Allocations => Parent.GetAllocations(this); } }