public virtual void When(IShipmentPackageStateCreated e) { ThrowOnWrongEvent(e); this.ShipmentBoxTypeId = e.ShipmentBoxTypeId; this.DateCreated = e.DateCreated; this.BoxLength = e.BoxLength; this.BoxHeight = e.BoxHeight; this.BoxWidth = e.BoxWidth; this.DimensionUomId = e.DimensionUomId; this.Weight = e.Weight; this.WeightUomId = e.WeightUomId; this.InsuredValue = e.InsuredValue; this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool); this.Deleted = false; this.CreatedBy = e.CreatedBy; this.CreatedAt = e.CreatedAt; foreach (IShipmentPackageContentStateCreated innerEvent in e.ShipmentPackageContentEvents) { IShipmentPackageContentState innerState = this.ShipmentPackageContents.Get(innerEvent.GlobalId.ShipmentItemSeqId, true); innerState.Mutate(innerEvent); } }
public IShipmentPackageContentState Get(ShipmentPackageContentId id, bool nullAllowed) { IShipmentPackageContentState state = CurrentSession.Get <ShipmentPackageContentState>(id); if (!nullAllowed && state == null) { state = new ShipmentPackageContentState(); (state as ShipmentPackageContentState).ShipmentPackageContentId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IShipmentPackageContentState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public void Delete(IShipmentPackageContentState state) { IShipmentPackageContentState s = state; if (ReadOnlyProxyGenerator != null) { s = ReadOnlyProxyGenerator.GetTarget <IShipmentPackageContentState>(state); } var saveable = s as ISaveable; if (saveable != null) { saveable.Save(); } CurrentSession.Delete(s); }
public void AddToSave(IShipmentPackageContentState state) { throw new NotSupportedException(); }
public virtual void When(IShipmentPackageStateMergePatched e) { ThrowOnWrongEvent(e); if (e.ShipmentBoxTypeId == null) { if (e.IsPropertyShipmentBoxTypeIdRemoved) { this.ShipmentBoxTypeId = default(string); } } else { this.ShipmentBoxTypeId = e.ShipmentBoxTypeId; } if (e.DateCreated == null) { if (e.IsPropertyDateCreatedRemoved) { this.DateCreated = default(DateTime?); } } else { this.DateCreated = e.DateCreated; } if (e.BoxLength == null) { if (e.IsPropertyBoxLengthRemoved) { this.BoxLength = default(decimal?); } } else { this.BoxLength = e.BoxLength; } if (e.BoxHeight == null) { if (e.IsPropertyBoxHeightRemoved) { this.BoxHeight = default(decimal?); } } else { this.BoxHeight = e.BoxHeight; } if (e.BoxWidth == null) { if (e.IsPropertyBoxWidthRemoved) { this.BoxWidth = default(decimal?); } } else { this.BoxWidth = e.BoxWidth; } if (e.DimensionUomId == null) { if (e.IsPropertyDimensionUomIdRemoved) { this.DimensionUomId = default(string); } } else { this.DimensionUomId = e.DimensionUomId; } if (e.Weight == null) { if (e.IsPropertyWeightRemoved) { this.Weight = default(decimal?); } } else { this.Weight = e.Weight; } if (e.WeightUomId == null) { if (e.IsPropertyWeightUomIdRemoved) { this.WeightUomId = default(string); } } else { this.WeightUomId = e.WeightUomId; } if (e.InsuredValue == null) { if (e.IsPropertyInsuredValueRemoved) { this.InsuredValue = default(decimal?); } } else { this.InsuredValue = e.InsuredValue; } if (e.Active == null) { if (e.IsPropertyActiveRemoved) { this.Active = default(bool); } } else { this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool); } this.UpdatedBy = e.CreatedBy; this.UpdatedAt = e.CreatedAt; foreach (IShipmentPackageContentEvent innerEvent in e.ShipmentPackageContentEvents) { IShipmentPackageContentState innerState = this.ShipmentPackageContents.Get(innerEvent.GlobalId.ShipmentItemSeqId); innerState.Mutate(innerEvent); var removed = innerEvent as IShipmentPackageContentStateRemoved; if (removed != null) { this.ShipmentPackageContents.Remove(innerState); } } }
public virtual void Remove(IShipmentPackageContentState state) { this._removedShipmentPackageContentStates.Add(state.GlobalId, state); }
public ShipmentPackageContentStateDtoWrapper(IShipmentPackageContentState state) { this._state = state; }
public virtual void AddToSave(IShipmentPackageContentState state) { this._loadedShipmentPackageContentStates[state.GlobalId] = state; }
public ShipmentPackageContentStateDtoWrapper() { this._state = new ShipmentPackageContentState(); }
public static TCreateShipmentPackageContent ToCreateShipmentPackageContent <TCreateShipmentPackageContent>(this IShipmentPackageContentState state) where TCreateShipmentPackageContent : ICreateShipmentPackageContent, new() { var cmd = new TCreateShipmentPackageContent(); cmd.ShipmentItemSeqId = state.ShipmentItemSeqId; cmd.Quantity = state.Quantity; cmd.SubProductId = state.SubProductId; cmd.SubProductQuantity = state.SubProductQuantity; cmd.Active = ((IShipmentPackageContentStateProperties)state).Active; cmd.ShipmentPackageId = state.ShipmentPackageId; return(cmd); }
public static TMergePatchShipmentPackageContent ToMergePatchShipmentPackageContent <TMergePatchShipmentPackageContent>(this IShipmentPackageContentState state) where TMergePatchShipmentPackageContent : IMergePatchShipmentPackageContent, new() { var cmd = new TMergePatchShipmentPackageContent(); cmd.ShipmentItemSeqId = state.ShipmentItemSeqId; cmd.Quantity = state.Quantity; cmd.SubProductId = state.SubProductId; cmd.SubProductQuantity = state.SubProductQuantity; cmd.Active = ((IShipmentPackageContentStateProperties)state).Active; cmd.ShipmentPackageId = state.ShipmentPackageId; if (state.Quantity == null) { cmd.IsPropertyQuantityRemoved = true; } if (state.SubProductId == null) { cmd.IsPropertySubProductIdRemoved = true; } if (state.SubProductQuantity == null) { cmd.IsPropertySubProductQuantityRemoved = true; } return(cmd); }
public static TRemoveShipmentPackageContent ToRemoveShipmentPackageContent <TRemoveShipmentPackageContent>(this IShipmentPackageContentState state) where TRemoveShipmentPackageContent : IRemoveShipmentPackageContent, new() { var cmd = new TRemoveShipmentPackageContent(); cmd.ShipmentItemSeqId = state.ShipmentItemSeqId; return(cmd); }
public static IShipmentPackageContentCommand ToCreateOrMergePatchShipmentPackageContent <TCreateShipmentPackageContent, TMergePatchShipmentPackageContent>(this IShipmentPackageContentState state) where TCreateShipmentPackageContent : ICreateShipmentPackageContent, new() where TMergePatchShipmentPackageContent : IMergePatchShipmentPackageContent, new() { bool bUnsaved = ((IShipmentPackageContentState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreateShipmentPackageContent <TCreateShipmentPackageContent>()); } else { return(state.ToMergePatchShipmentPackageContent <TMergePatchShipmentPackageContent>()); } }