public DtoAttributeUseStates(IAttributeSetState outerState, IEnumerable <IAttributeUseState> innerStates) { this._outerState = outerState; if (innerStates == null) { this._innerStates = new IAttributeUseState[] { }; } else { this._innerStates = innerStates; } }
public IAttributeSetState Get(string id, bool nullAllowed) { IAttributeSetState state = CurrentSession.Get <AttributeSetState> (id); if (!nullAllowed && state == null) { state = new AttributeSetState(); (state as AttributeSetState).AttributeSetId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IAttributeSetState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames)); } return(state); }
public async Task <IAttributeSetState> GetAsync(string attributeSetId) { IAttributeSetState state = null; var idObj = attributeSetId; var uriParameters = new AttributeSetUriParameters(); uriParameters.Id = idObj; var req = new AttributeSetGetRequest(uriParameters); var resp = await _ramlClient.AttributeSet.Get(req); AttributeSetProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToAttributeSetState(); return(state); }
public void Save(IAttributeSetState state) { IAttributeSetState s = state; if (ReadOnlyProxyGenerator != null) { s = ReadOnlyProxyGenerator.GetTarget <IAttributeSetState>(state); } CurrentSession.SaveOrUpdate(s); var saveable = s as ISaveable; if (saveable != null) { saveable.Save(); } }
public static IAttributeSetCommand ToCreateOrMergePatchAttributeSet <TCreateAttributeSet, TMergePatchAttributeSet, TCreateAttributeUse, TMergePatchAttributeUse>(this IAttributeSetState state) where TCreateAttributeSet : ICreateAttributeSet, new() where TMergePatchAttributeSet : IMergePatchAttributeSet, new() where TCreateAttributeUse : ICreateAttributeUse, new() where TMergePatchAttributeUse : IMergePatchAttributeUse, new() { bool bUnsaved = ((IAttributeSetState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreateAttributeSet <TCreateAttributeSet, TCreateAttributeUse>()); } else { return(state.ToMergePatchAttributeSet <TMergePatchAttributeSet, TCreateAttributeUse, TMergePatchAttributeUse>()); } }
}// END Map(ICreate... //////////////////////////// protected virtual IAttributeUseStateMergePatched MapMergePatch(IMergePatchAttributeUse c, IAttributeSetCommand outerCommand, long version, IAttributeSetState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new AttributeUseStateEventId(c.AttributeSetId, c.AttributeId, version); IAttributeUseStateMergePatched e = NewAttributeUseStateMergePatched(stateEventId); var s = outerState.AttributeUses.Get(c.AttributeId); e.SequenceNumber = c.SequenceNumber; e.Active = c.Active; e.IsPropertySequenceNumberRemoved = c.IsPropertySequenceNumberRemoved; e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = DateTime.Now; return(e); }// END Map(IMergePatch... ////////////////////////////
public AttributeSetAggregate(IAttributeSetState state) { _state = state; }
}// END ThrowOnInconsistentCommands ///////////////////// protected virtual IAttributeUseStateEvent Map(IAttributeUseCommand c, IAttributeSetCommand outerCommand, long version, IAttributeSetState outerState) { var create = (c.CommandType == CommandType.Create) ? (c as ICreateAttributeUse) : null; if (create != null) { return(MapCreate(create, outerCommand, version, outerState)); } var merge = (c.CommandType == CommandType.MergePatch) ? (c as IMergePatchAttributeUse) : null; if (merge != null) { return(MapMergePatch(merge, outerCommand, version, outerState)); } var remove = (c.CommandType == CommandType.Remove) ? (c as IRemoveAttributeUse) : null; if (remove != null) { return(MapRemove(remove, outerCommand, version)); } throw new NotSupportedException(); }
protected virtual IAttributeUseStateCreated MapCreate(ICreateAttributeUse c, IAttributeSetCommand outerCommand, long version, IAttributeSetState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new AttributeUseStateEventId(c.AttributeSetId, c.AttributeId, version); IAttributeUseStateCreated e = NewAttributeUseStateCreated(stateEventId); var s = outerState.AttributeUses.Get(c.AttributeId, true); e.SequenceNumber = c.SequenceNumber; e.Active = c.Active; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = DateTime.Now; return(e); }// END Map(ICreate... ////////////////////////////
internal static IDictionary <string, string> GetPropertyExtensionFieldDictionary(IAttributeSetState attrSet, Func <string, IAttributeState> getAttributeState) { var pDic = new Dictionary <string, string>(); if (attrSet == null) { return(pDic); } foreach (var au in attrSet.AttributeUses) { var a = getAttributeState(au.AttributeId); if (a != null) { PropertyExtensionFieldDictionaryAdd(pDic, a); } } return(pDic); }
public override IAttributeSetAggregate GetAttributeSetAggregate(IAttributeSetState state) { return(new AttributeSetAggregate(state)); }
public static TMergePatchAttributeSet ToMergePatchAttributeSet <TMergePatchAttributeSet, TCreateAttributeUse, TMergePatchAttributeUse>(this IAttributeSetState state) where TMergePatchAttributeSet : IMergePatchAttributeSet, new() where TCreateAttributeUse : ICreateAttributeUse, new() where TMergePatchAttributeUse : IMergePatchAttributeUse, new() { var cmd = new TMergePatchAttributeSet(); cmd.Version = ((IAttributeSetStateProperties)state).Version; cmd.AttributeSetId = state.AttributeSetId; cmd.Name = state.Name; cmd.OrganizationId = state.OrganizationId; cmd.Description = state.Description; cmd.SerialNumberAttributeId = state.SerialNumberAttributeId; cmd.LotAttributeId = state.LotAttributeId; cmd.ReferenceId = state.ReferenceId; cmd.Active = ((IAttributeSetStateProperties)state).Active; if (state.Name == null) { cmd.IsPropertyNameRemoved = true; } if (state.OrganizationId == null) { cmd.IsPropertyOrganizationIdRemoved = true; } if (state.Description == null) { cmd.IsPropertyDescriptionRemoved = true; } if (state.SerialNumberAttributeId == null) { cmd.IsPropertySerialNumberAttributeIdRemoved = true; } if (state.LotAttributeId == null) { cmd.IsPropertyLotAttributeIdRemoved = true; } if (state.ReferenceId == null) { cmd.IsPropertyReferenceIdRemoved = true; } foreach (var d in state.AttributeUses) { var c = d.ToCreateOrMergePatchAttributeUse <TCreateAttributeUse, TMergePatchAttributeUse>(); cmd.AttributeUseCommands.Add(c); } return(cmd); }
public AttributeUseStates(IAttributeSetState outerState) { this._attributeSetState = outerState; }
protected bool IsRepeatedCommand(IAttributeSetCommand command, IEventStoreAggregateId eventStoreAggregateId, IAttributeSetState state) { bool repeated = false; if (((IAttributeSetStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.FindLastEvent(typeof(IAttributeSetStateEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
public abstract IAttributeSetAggregate GetAttributeSetAggregate(IAttributeSetState state);
private void Persist(IEventStoreAggregateId eventStoreAggregateId, IAttributeSetAggregate aggregate, IAttributeSetState state) { EventStore.AppendEvents(eventStoreAggregateId, ((IAttributeSetStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); }); if (AggregateEventListener != null) { AggregateEventListener.EventAppended(new AggregateEvent <IAttributeSetAggregate, IAttributeSetState>(aggregate, state, aggregate.Changes)); } }
public AttributeSetStateDtoWrapper(IAttributeSetState state) { this._state = state; }
public AttributeSetStateDtoWrapper() { this._state = new AttributeSetState(); }
public static TCreateAttributeSet ToCreateAttributeSet <TCreateAttributeSet, TCreateAttributeUse>(this IAttributeSetState state) where TCreateAttributeSet : ICreateAttributeSet, new() where TCreateAttributeUse : ICreateAttributeUse, new() { var cmd = new TCreateAttributeSet(); cmd.Version = ((IAttributeSetStateProperties)state).Version; cmd.AttributeSetId = state.AttributeSetId; cmd.Name = state.Name; cmd.OrganizationId = state.OrganizationId; cmd.Description = state.Description; cmd.SerialNumberAttributeId = state.SerialNumberAttributeId; cmd.LotAttributeId = state.LotAttributeId; cmd.ReferenceId = state.ReferenceId; cmd.Active = ((IAttributeSetStateProperties)state).Active; foreach (var d in state.AttributeUses) { var c = d.ToCreateAttributeUse <TCreateAttributeUse>(); cmd.AttributeUses.Add(c); } return(cmd); }
public AttributeUseStates(IAttributeSetState outerState) { this._attributeSetState = outerState; this._forReapplying = outerState.ForReapplying; }