public static TMergePatchUomType ToMergePatchUomType <TMergePatchUomType>(this IUomTypeState state)
            where TMergePatchUomType : IMergePatchUomType, new()
        {
            var cmd = new TMergePatchUomType();

            cmd.Version = ((IUomTypeStateProperties)state).Version;

            cmd.UomTypeId    = state.UomTypeId;
            cmd.ParentTypeId = state.ParentTypeId;
            cmd.HasTable     = state.HasTable;
            cmd.Description  = state.Description;
            cmd.Active       = ((IUomTypeStateProperties)state).Active;

            if (state.ParentTypeId == null)
            {
                cmd.IsPropertyParentTypeIdRemoved = true;
            }
            if (state.HasTable == null)
            {
                cmd.IsPropertyHasTableRemoved = true;
            }
            if (state.Description == null)
            {
                cmd.IsPropertyDescriptionRemoved = true;
            }
            return(cmd);
        }
        public static TDeleteUomType ToDeleteUomType <TDeleteUomType>(this IUomTypeState state)
            where TDeleteUomType : IDeleteUomType, new()
        {
            var cmd = new TDeleteUomType();

            cmd.UomTypeId = state.UomTypeId;
            cmd.Version   = ((IUomTypeStateProperties)state).Version;

            return(cmd);
        }
        public IUomTypeState Get(string id, bool nullAllowed)
        {
            IUomTypeState state = CurrentSession.Get <UomTypeState> (id);

            if (!nullAllowed && state == null)
            {
                state = new UomTypeState();
                (state as UomTypeState).UomTypeId = id;
            }
            return(state);
        }
        public static TCreateUomType ToCreateUomType <TCreateUomType>(this IUomTypeState state)
            where TCreateUomType : ICreateUomType, new()
        {
            var cmd = new TCreateUomType();

            cmd.Version = ((IUomTypeStateProperties)state).Version;

            cmd.UomTypeId    = state.UomTypeId;
            cmd.ParentTypeId = state.ParentTypeId;
            cmd.HasTable     = state.HasTable;
            cmd.Description  = state.Description;
            cmd.Active       = ((IUomTypeStateProperties)state).Active;
            return(cmd);
        }
        public void Save(IUomTypeState state)
        {
            IUomTypeState s = state;

            CurrentSession.SaveOrUpdate(s);

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Flush();
        }
Beispiel #6
0
        public async Task <IUomTypeState> GetAsync(string uomTypeId)
        {
            IUomTypeState state         = null;
            var           idObj         = uomTypeId;
            var           uriParameters = new UomTypeUriParameters();

            uriParameters.Id = idObj;

            var req = new UomTypeGetRequest(uriParameters);

            var resp = await _ramlClient.UomType.Get(req);

            UomTypeProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToUomTypeState();
            return(state);
        }
Beispiel #7
0
        public IUomTypeState Get(string id)
        {
            IUomTypeState state = CurrentSession.Get <UomTypeState>(id);

            return(state);
        }
 public override IUomTypeAggregate GetUomTypeAggregate(IUomTypeState state)
 {
     return(new UomTypeAggregate(state));
 }
        public static IUomTypeCommand ToCreateOrMergePatchUomType <TCreateUomType, TMergePatchUomType>(this IUomTypeState state)
            where TCreateUomType : ICreateUomType, new()
            where TMergePatchUomType : IMergePatchUomType, new()
        {
            bool bUnsaved = ((IUomTypeState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateUomType <TCreateUomType>());
            }
            else
            {
                return(state.ToMergePatchUomType <TMergePatchUomType>());
            }
        }
Beispiel #10
0
 public UomTypeStateDtoWrapper(IUomTypeState state)
 {
     this._state = state;
 }
Beispiel #11
0
 public UomTypeStateDtoWrapper()
 {
     this._state = new UomTypeState();
 }
Beispiel #12
0
 public UomTypeAggregate(IUomTypeState state)
 {
     _state = state;
 }
        protected bool IsRepeatedCommand(IUomTypeCommand command, IEventStoreAggregateId eventStoreAggregateId, IUomTypeState state)
        {
            bool repeated = false;

            if (((IUomTypeStateProperties)state).Version == command.AggregateVersion + 1)
            {
                if (state.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, IUomTypeAggregate aggregate, IUomTypeState state)
 {
     StateRepository.Save(state);
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <IUomTypeAggregate, IUomTypeState>(aggregate, state, aggregate.Changes));
     }
 }
 public abstract IUomTypeAggregate GetUomTypeAggregate(IUomTypeState state);