public virtual void When(IAttributeSetStateCreated e) { ThrowOnWrongEvent(e); this.AttributeSetName = e.AttributeSetName; this.OrganizationId = e.OrganizationId; this.Description = e.Description; this.ReferenceId = e.ReferenceId; if (e.IsInstanceAttributeSet != null) { this.IsInstanceAttributeSet = (e.IsInstanceAttributeSet != null && e.IsInstanceAttributeSet.HasValue) ? e.IsInstanceAttributeSet.Value : default(bool); } if (e.IsMandatory != null) { this.IsMandatory = (e.IsMandatory != null && e.IsMandatory.HasValue) ? e.IsMandatory.Value : default(bool); } 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 (IAttributeUseStateCreated innerEvent in e.AttributeUseEvents) { IAttributeUseState innerState = this.AttributeUses.Get(innerEvent.GlobalId.AttributeId, true); innerState.Mutate(innerEvent); } }
public virtual void When(IAttributeSetStateCreated e) { ThrowOnWrongEvent(e); this.Name = e.Name; this.OrganizationId = e.OrganizationId; this.Description = e.Description; this.SerialNumberAttributeId = e.SerialNumberAttributeId; this.LotAttributeId = e.LotAttributeId; this.ReferenceId = e.ReferenceId; 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 (IAttributeUseStateCreated innerEvent in e.AttributeUseEvents) { IAttributeUseState innerState = this.AttributeUses.Get(innerEvent.GlobalId.AttributeId); innerState.Mutate(innerEvent); } }
public static TRemoveAttributeUse ToRemoveAttributeUse <TRemoveAttributeUse>(this IAttributeUseState state) where TRemoveAttributeUse : IRemoveAttributeUse, new() { var cmd = new TRemoveAttributeUse(); cmd.AttributeId = state.AttributeId; return(cmd); }
public void Delete(IAttributeUseState state) { var saveable = state as ISaveable; if (saveable != null) { saveable.Save(); } CurrentSession.Delete(state); }
public void Save(IAttributeUseState state) { CurrentSession.SaveOrUpdate(state); var saveable = state as ISaveable; if (saveable != null) { saveable.Save(); } }
public static TCreateAttributeUse ToCreateAttributeUse <TCreateAttributeUse>(this IAttributeUseState state) where TCreateAttributeUse : ICreateAttributeUse, new() { var cmd = new TCreateAttributeUse(); cmd.AttributeId = state.AttributeId; cmd.SequenceNumber = state.SequenceNumber; cmd.Active = ((IAttributeUseStateProperties)state).Active; cmd.AttributeSetId = state.AttributeSetId; return(cmd); }
public IAttributeUseState Get(AttributeSetAttributeUseId id) { IAttributeUseState state = CurrentSession.Get <AttributeUseState>(id); if (state == null) { state = new AttributeUseState(); (state as AttributeUseState).AttributeSetAttributeUseId = id; } return(state); }
public IAttributeUseState Get(AttributeSetAttributeUseId id, bool nullAllowed) { IAttributeUseState state = CurrentSession.Get <AttributeUseState>(id); if (!nullAllowed && state == null) { state = new AttributeUseState(); (state as AttributeUseState).AttributeSetAttributeUseId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IAttributeUseState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public void Delete(IAttributeUseState state) { IAttributeUseState s = state; if (ReadOnlyProxyGenerator != null) { s = ReadOnlyProxyGenerator.GetTarget <IAttributeUseState>(state); } var saveable = s as ISaveable; if (saveable != null) { saveable.Save(); } CurrentSession.Delete(s); }
public AttributeUseStateDtoWrapper(IAttributeUseState state) { this._state = state; }
public AttributeUseStateDtoWrapper() { this._state = new AttributeUseState(); }
public static IAttributeUseCommand ToCreateOrMergePatchAttributeUse <TCreateAttributeUse, TMergePatchAttributeUse>(this IAttributeUseState state) where TCreateAttributeUse : ICreateAttributeUse, new() where TMergePatchAttributeUse : IMergePatchAttributeUse, new() { bool bUnsaved = ((IAttributeUseState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreateAttributeUse <TCreateAttributeUse>()); } else { return(state.ToMergePatchAttributeUse <TMergePatchAttributeUse>()); } }
public virtual void When(IAttributeSetStateMergePatched e) { ThrowOnWrongEvent(e); if (e.AttributeSetName == null) { if (e.IsPropertyAttributeSetNameRemoved) { this.AttributeSetName = default(string); } } else { this.AttributeSetName = e.AttributeSetName; } if (e.OrganizationId == null) { if (e.IsPropertyOrganizationIdRemoved) { this.OrganizationId = default(string); } } else { this.OrganizationId = e.OrganizationId; } if (e.Description == null) { if (e.IsPropertyDescriptionRemoved) { this.Description = default(string); } } else { this.Description = e.Description; } if (e.ReferenceId == null) { if (e.IsPropertyReferenceIdRemoved) { this.ReferenceId = default(string); } } else { this.ReferenceId = e.ReferenceId; } if (e.IsInstanceAttributeSet == null) { if (e.IsPropertyIsInstanceAttributeSetRemoved) { this.IsInstanceAttributeSet = default(bool); } } else { this.IsInstanceAttributeSet = (e.IsInstanceAttributeSet != null && e.IsInstanceAttributeSet.HasValue) ? e.IsInstanceAttributeSet.Value : default(bool); } if (e.IsMandatory == null) { if (e.IsPropertyIsMandatoryRemoved) { this.IsMandatory = default(bool); } } else { this.IsMandatory = (e.IsMandatory != null && e.IsMandatory.HasValue) ? e.IsMandatory.Value : default(bool); } 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 (IAttributeUseEvent innerEvent in e.AttributeUseEvents) { IAttributeUseState innerState = this.AttributeUses.Get(innerEvent.GlobalId.AttributeId); innerState.Mutate(innerEvent); var removed = innerEvent as IAttributeUseStateRemoved; if (removed != null) { this.AttributeUses.Remove(innerState); } } }
public virtual void Remove(IAttributeUseState state) { this._removedAttributeUseStates.Add(state.GlobalId, state); }
public virtual void AddToSave(IAttributeUseState state) { this._loadedAttributeUseStates[state.GlobalId] = state; }
public void AddToSave(IAttributeUseState state) { throw new NotSupportedException(); }