public ISupplierProductState Get(SupplierProductId id) { ISupplierProductState state = CurrentSession.Get <SupplierProductState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <ISupplierProductState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public ISupplierProductState Get(SupplierProductId id, bool nullAllowed) { ISupplierProductState state = CurrentSession.Get <SupplierProductState> (id); if (!nullAllowed && state == null) { state = new SupplierProductState(); (state as SupplierProductState).SupplierProductId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <ISupplierProductState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public async Task <ISupplierProductState> GetAsync(SupplierProductId supplierProductId) { ISupplierProductState state = null; var idObj = SupplierProductProxyUtils.ToIdString(supplierProductId); var uriParameters = new SupplierProductUriParameters(); uriParameters.Id = idObj; var req = new SupplierProductGetRequest(uriParameters); var resp = await _ramlClient.SupplierProduct.Get(req); SupplierProductProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToSupplierProductState(); return(state); }
public void Save(ISupplierProductState state) { ISupplierProductState s = state; if (ReadOnlyProxyGenerator != null) { s = ReadOnlyProxyGenerator.GetTarget <ISupplierProductState>(state); } CurrentSession.SaveOrUpdate(s); var saveable = s as ISaveable; if (saveable != null) { saveable.Save(); } CurrentSession.Flush(); }
public SupplierProductStateDtoWrapper(ISupplierProductState state) { this._state = state; }
public SupplierProductStateDtoWrapper() { this._state = new SupplierProductState(); }
public override ISupplierProductAggregate GetSupplierProductAggregate(ISupplierProductState state) { return(new SupplierProductAggregate(state)); }
public static TMergePatchSupplierProduct ToMergePatchSupplierProduct <TMergePatchSupplierProduct>(this ISupplierProductState state) where TMergePatchSupplierProduct : IMergePatchSupplierProduct, new() { var cmd = new TMergePatchSupplierProduct(); cmd.Version = ((ISupplierProductStateProperties)state).Version; cmd.SupplierProductId = state.SupplierProductId; cmd.AvailableThruDate = state.AvailableThruDate; cmd.SupplierPrefOrderId = state.SupplierPrefOrderId; cmd.SupplierRatingTypeId = state.SupplierRatingTypeId; cmd.StandardLeadTimeDays = state.StandardLeadTimeDays; cmd.ManufacturingLeadTimeDays = state.ManufacturingLeadTimeDays; cmd.DeliveryLeadTimeDays = state.DeliveryLeadTimeDays; cmd.QuantityUomId = state.QuantityUomId; cmd.LastPrice = state.LastPrice; cmd.ShippingPrice = state.ShippingPrice; cmd.ExternalProductName = state.ExternalProductName; cmd.ExternalProductId = state.ExternalProductId; cmd.CanDropShip = state.CanDropShip; cmd.Comments = state.Comments; cmd.Active = ((ISupplierProductStateProperties)state).Active; if (state.AvailableThruDate == null) { cmd.IsPropertyAvailableThruDateRemoved = true; } if (state.SupplierPrefOrderId == null) { cmd.IsPropertySupplierPrefOrderIdRemoved = true; } if (state.SupplierRatingTypeId == null) { cmd.IsPropertySupplierRatingTypeIdRemoved = true; } if (state.StandardLeadTimeDays == null) { cmd.IsPropertyStandardLeadTimeDaysRemoved = true; } if (state.ManufacturingLeadTimeDays == null) { cmd.IsPropertyManufacturingLeadTimeDaysRemoved = true; } if (state.DeliveryLeadTimeDays == null) { cmd.IsPropertyDeliveryLeadTimeDaysRemoved = true; } if (state.QuantityUomId == null) { cmd.IsPropertyQuantityUomIdRemoved = true; } if (state.LastPrice == null) { cmd.IsPropertyLastPriceRemoved = true; } if (state.ShippingPrice == null) { cmd.IsPropertyShippingPriceRemoved = true; } if (state.ExternalProductName == null) { cmd.IsPropertyExternalProductNameRemoved = true; } if (state.ExternalProductId == null) { cmd.IsPropertyExternalProductIdRemoved = true; } if (state.Comments == null) { cmd.IsPropertyCommentsRemoved = true; } return(cmd); }
public static TDeleteSupplierProduct ToDeleteSupplierProduct <TDeleteSupplierProduct>(this ISupplierProductState state) where TDeleteSupplierProduct : IDeleteSupplierProduct, new() { var cmd = new TDeleteSupplierProduct(); cmd.SupplierProductId = state.SupplierProductId; cmd.Version = ((ISupplierProductStateProperties)state).Version; return(cmd); }
public static ISupplierProductCommand ToCreateOrMergePatchSupplierProduct <TCreateSupplierProduct, TMergePatchSupplierProduct>(this ISupplierProductState state) where TCreateSupplierProduct : ICreateSupplierProduct, new() where TMergePatchSupplierProduct : IMergePatchSupplierProduct, new() { bool bUnsaved = ((ISupplierProductState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreateSupplierProduct <TCreateSupplierProduct>()); } else { return(state.ToMergePatchSupplierProduct <TMergePatchSupplierProduct>()); } }
public static TCreateSupplierProduct ToCreateSupplierProduct <TCreateSupplierProduct>(this ISupplierProductState state) where TCreateSupplierProduct : ICreateSupplierProduct, new() { var cmd = new TCreateSupplierProduct(); cmd.Version = ((ISupplierProductStateProperties)state).Version; cmd.SupplierProductId = state.SupplierProductId; cmd.AvailableThruDate = state.AvailableThruDate; cmd.SupplierPrefOrderId = state.SupplierPrefOrderId; cmd.SupplierRatingTypeId = state.SupplierRatingTypeId; cmd.StandardLeadTimeDays = state.StandardLeadTimeDays; cmd.ManufacturingLeadTimeDays = state.ManufacturingLeadTimeDays; cmd.DeliveryLeadTimeDays = state.DeliveryLeadTimeDays; cmd.QuantityUomId = state.QuantityUomId; cmd.LastPrice = state.LastPrice; cmd.ShippingPrice = state.ShippingPrice; cmd.ExternalProductName = state.ExternalProductName; cmd.ExternalProductId = state.ExternalProductId; cmd.CanDropShip = state.CanDropShip; cmd.Comments = state.Comments; cmd.Active = ((ISupplierProductStateProperties)state).Active; return(cmd); }
protected bool IsRepeatedCommand(ISupplierProductCommand command, IEventStoreAggregateId eventStoreAggregateId, ISupplierProductState state) { bool repeated = false; if (((ISupplierProductStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.GetEvent(typeof(ISupplierProductEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
private void Persist(IEventStoreAggregateId eventStoreAggregateId, ISupplierProductAggregate aggregate, ISupplierProductState state) { EventStore.AppendEvents(eventStoreAggregateId, ((ISupplierProductStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); }); if (AggregateEventListener != null) { AggregateEventListener.EventAppended(new AggregateEvent <ISupplierProductAggregate, ISupplierProductState>(aggregate, state, aggregate.Changes)); } }
public abstract ISupplierProductAggregate GetSupplierProductAggregate(ISupplierProductState state);
public SupplierProductAggregate(ISupplierProductState state) { _state = state; }