Shipment.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq.Expressions;
  4. using InABox.Core;
  5. namespace Comal.Classes
  6. {
  7. public class ShipmentItemCount : CoreAggregate<Shipment, DeliveryItem, Guid>
  8. {
  9. public override Expression<Func<DeliveryItem, Guid>> Aggregate => x => x.ID;
  10. public override AggregateCalculation Calculation => AggregateCalculation.Count;
  11. public override Dictionary<Expression<Func<DeliveryItem, object>>, Expression<Func<Shipment, object>>> Links =>
  12. new Dictionary<Expression<Func<DeliveryItem, object>>, Expression<Func<Shipment, object>>>()
  13. {
  14. { DeliveryItem => DeliveryItem.Shipment.ID, Shipment => Shipment.ID }
  15. };
  16. }
  17. [UserTracking(typeof(Delivery))]
  18. public class Shipment : Entity, IPersistent, IRemotable, ILicense<LogisticsLicense>
  19. {
  20. [UniqueCodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)]
  21. [EditorSequence(1)]
  22. public string Code { get; set; }
  23. [TextBoxEditor]
  24. [EditorSequence(2)]
  25. public string Description { get; set; }
  26. [TextBoxEditor]
  27. [EditorSequence(3)]
  28. public string Type { get; set; }
  29. [CodeEditor(Editable = Editable.Disabled)]
  30. [EditorSequence(4)]
  31. public string BarCode { get; set; }
  32. = CoreUtils.RandomHexString(16);
  33. [EditorSequence(5)]
  34. [EntityRelationship(DeleteAction.SetNull)]
  35. public GPSTrackerLink Tracker { get; set; }
  36. [Obsolete("Replaced by Tracker")]
  37. [ObsoleteProperty(nameof(Tracker))]
  38. public GPSTrackerLink TrackerLink
  39. {
  40. get => Tracker;
  41. set { }
  42. }
  43. [EditorSequence(6)]
  44. [EntityRelationship(DeleteAction.SetNull)]
  45. public DeliveryLink Delivery { get; set; }
  46. [EditorSequence(7)]
  47. [IntegerEditor(Editable = Editable.Hidden)]
  48. [Aggregate(typeof(ShipmentItemCount))]
  49. public int ItemCount { get; set; }
  50. [Obsolete("Replaced with GPSTrackerLink")]
  51. [NullEditor]
  52. public Guid GPSTrackerID { get; set; }
  53. public override string ToString()
  54. {
  55. return string.Format("{0}: {1}", Code, Description);
  56. }
  57. static Shipment()
  58. {
  59. DefaultColumns.Add<Shipment>(x => x.Code);
  60. DefaultColumns.Add<Shipment>(x => x.Description);
  61. }
  62. }
  63. }