| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using InABox.Core;
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Comal.Classes
- {
- public class ProductInstanceLookups : EntityLookup<ProductInstance>, ILookupDefinition<ProductInstance, Product>
- {
-
- #region Default Lookups (should always be empty)
- public override Filter<ProductInstance>? DefineFilter()
- {
- return new Filter<ProductInstance>().None();
- }
- public override SortOrder<ProductInstance> DefineSortOrder()
- {
- return new SortOrder<ProductInstance>(x => x.Sequence);
- }
- #endregion
-
- public override string FormatLookup(Dictionary<string, object?> values, IEnumerable<string> exclude)
- {
- List<object> result = new List<object>();
- if (values.TryGetValue("Dimensions.UnitSize", out object size) && !String.IsNullOrWhiteSpace(size?.ToString()))
- result.Add(size);
- if (values.TryGetValue("Style.Description", out object description) && !String.IsNullOrWhiteSpace(description?.ToString()))
- result.Add(description);
- return String.Join(" ", result);
- }
-
- #region Lookups for Products
-
- public Filter<ProductInstance>? DefineFilter(Product[] items)
- {
- if (items.Length == 0)
- {
- return new Filter<ProductInstance>().None();
- }
- else
- {
- var filter = new Filters<ProductInstance>();
- foreach (var item in items)
- {
- filter.Add(new Filter<ProductInstance>(x => x.Product.ID).IsEqualTo(item.ID));
- }
- return filter.Combine();
- }
- }
- public Columns<Product> DefineFilterColumns() => new Columns<Product>(x => x.ID);
-
- #endregion
- }
- }
|