public static TMergePatchUom ToMergePatchUom <TMergePatchUom>(this IUomState state) where TMergePatchUom : IMergePatchUom, new() { var cmd = new TMergePatchUom(); cmd.Version = ((IUomStateProperties)state).Version; cmd.UomId = state.UomId; cmd.UomTypeId = state.UomTypeId; cmd.Abbreviation = state.Abbreviation; cmd.Description = state.Description; cmd.Active = ((IUomStateProperties)state).Active; if (state.UomTypeId == null) { cmd.IsPropertyUomTypeIdRemoved = true; } if (state.Abbreviation == null) { cmd.IsPropertyAbbreviationRemoved = true; } if (state.Description == null) { cmd.IsPropertyDescriptionRemoved = true; } return(cmd); }
public IUomState Get(string id) { IUomState state = CurrentSession.Get <UomState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IUomState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public static TDeleteUom ToDeleteUom <TDeleteUom>(this IUomState state) where TDeleteUom : IDeleteUom, new() { var cmd = new TDeleteUom(); cmd.UomId = state.UomId; cmd.Version = ((IUomStateProperties)state).Version; return(cmd); }
public static TCreateUom ToCreateUom <TCreateUom>(this IUomState state) where TCreateUom : ICreateUom, new() { var cmd = new TCreateUom(); cmd.Version = ((IUomStateProperties)state).Version; cmd.UomId = state.UomId; cmd.UomTypeId = state.UomTypeId; cmd.Abbreviation = state.Abbreviation; cmd.Description = state.Description; cmd.Active = ((IUomStateProperties)state).Active; return(cmd); }
public IUomState Get(string id, bool nullAllowed) { IUomState state = CurrentSession.Get <UomState> (id); if (!nullAllowed && state == null) { state = new UomState(); (state as UomState).UomId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IUomState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public async Task <IUomState> GetAsync(string uomId) { IUomState state = null; var idObj = uomId; var uriParameters = new UomUriParameters(); uriParameters.Id = idObj; var req = new UomGetRequest(uriParameters); var resp = await _ramlClient.Uom.Get(req); UomProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToUomState(); return(state); }
public void Save(IUomState state) { IUomState s = state; if (ReadOnlyProxyGenerator != null) { s = ReadOnlyProxyGenerator.GetTarget <IUomState>(state); } CurrentSession.SaveOrUpdate(s); var saveable = s as ISaveable; if (saveable != null) { saveable.Save(); } CurrentSession.Flush(); }
protected bool IsRepeatedCommand(IUomCommand command, IEventStoreAggregateId eventStoreAggregateId, IUomState state) { bool repeated = false; if (((IUomStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.GetEvent(typeof(IUomEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
private void Persist(IEventStoreAggregateId eventStoreAggregateId, IUomAggregate aggregate, IUomState state) { EventStore.AppendEvents(eventStoreAggregateId, ((IUomStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); }); if (AggregateEventListener != null) { AggregateEventListener.EventAppended(new AggregateEvent <IUomAggregate, IUomState>(aggregate, state, aggregate.Changes)); } }
public abstract IUomAggregate GetUomAggregate(IUomState state);
public UomAggregate(IUomState state) { _state = state; }
public UomStateDtoWrapper(IUomState state) { this._state = state; }
public UomStateDtoWrapper() { this._state = new UomState(); }
public override IUomAggregate GetUomAggregate(IUomState state) { return(new UomAggregate(state)); }
public static IUomCommand ToCreateOrMergePatchUom <TCreateUom, TMergePatchUom>(this IUomState state) where TCreateUom : ICreateUom, new() where TMergePatchUom : IMergePatchUom, new() { bool bUnsaved = ((IUomState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreateUom <TCreateUom>()); } else { return(state.ToMergePatchUom <TMergePatchUom>()); } }