예제 #1
0
        public static TDeleteShipmentType ToDeleteShipmentType <TDeleteShipmentType>(this IShipmentTypeState state)
            where TDeleteShipmentType : IDeleteShipmentType, new()
        {
            var cmd = new TDeleteShipmentType();

            cmd.ShipmentTypeId = state.ShipmentTypeId;
            cmd.Version        = ((IShipmentTypeStateProperties)state).Version;

            return(cmd);
        }
예제 #2
0
        public IShipmentTypeState Get(string id, bool nullAllowed)
        {
            IShipmentTypeState state = CurrentSession.Get <ShipmentTypeState> (id);

            if (!nullAllowed && state == null)
            {
                state = new ShipmentTypeState();
                (state as ShipmentTypeState).ShipmentTypeId = id;
            }
            return(state);
        }
예제 #3
0
        public void Save(IShipmentTypeState state)
        {
            IShipmentTypeState s = state;

            CurrentSession.SaveOrUpdate(s);

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Flush();
        }
예제 #4
0
        public static TCreateShipmentType ToCreateShipmentType <TCreateShipmentType>(this IShipmentTypeState state)
            where TCreateShipmentType : ICreateShipmentType, new()
        {
            var cmd = new TCreateShipmentType();

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

            cmd.ShipmentTypeId = state.ShipmentTypeId;
            cmd.ParentTypeId   = state.ParentTypeId;
            cmd.HasTable       = state.HasTable;
            cmd.Description    = state.Description;
            cmd.Active         = ((IShipmentTypeStateProperties)state).Active;
            return(cmd);
        }
        public async Task <IShipmentTypeState> GetAsync(string shipmentTypeId)
        {
            IShipmentTypeState state = null;
            var idObj         = shipmentTypeId;
            var uriParameters = new ShipmentTypeUriParameters();

            uriParameters.Id = idObj;

            var req = new ShipmentTypeGetRequest(uriParameters);

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

            ShipmentTypeProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToShipmentTypeState();
            return(state);
        }
        public IShipmentTypeState Get(string id)
        {
            IShipmentTypeState state = CurrentSession.Get <ShipmentTypeState>(id);

            return(state);
        }
예제 #7
0
        protected bool IsRepeatedCommand(IShipmentTypeCommand command, IEventStoreAggregateId eventStoreAggregateId, IShipmentTypeState state)
        {
            bool repeated = false;

            if (((IShipmentTypeStateProperties)state).Version == command.AggregateVersion + 1)
            {
                if (state.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
예제 #8
0
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, IShipmentTypeAggregate aggregate, IShipmentTypeState state)
 {
     StateRepository.Save(state);
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <IShipmentTypeAggregate, IShipmentTypeState>(aggregate, state, aggregate.Changes));
     }
 }
예제 #9
0
 public abstract IShipmentTypeAggregate GetShipmentTypeAggregate(IShipmentTypeState state);
예제 #10
0
 public ShipmentTypeStateDtoWrapper(IShipmentTypeState state)
 {
     this._state = state;
 }
예제 #11
0
 public ShipmentTypeStateDtoWrapper()
 {
     this._state = new ShipmentTypeState();
 }
예제 #12
0
 public ShipmentTypeAggregate(IShipmentTypeState state)
 {
     _state = state;
 }
예제 #13
0
        public static TMergePatchShipmentType ToMergePatchShipmentType <TMergePatchShipmentType>(this IShipmentTypeState state)
            where TMergePatchShipmentType : IMergePatchShipmentType, new()
        {
            var cmd = new TMergePatchShipmentType();

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

            cmd.ShipmentTypeId = state.ShipmentTypeId;
            cmd.ParentTypeId   = state.ParentTypeId;
            cmd.HasTable       = state.HasTable;
            cmd.Description    = state.Description;
            cmd.Active         = ((IShipmentTypeStateProperties)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);
        }
예제 #14
0
        public static IShipmentTypeCommand ToCreateOrMergePatchShipmentType <TCreateShipmentType, TMergePatchShipmentType>(this IShipmentTypeState state)
            where TCreateShipmentType : ICreateShipmentType, new()
            where TMergePatchShipmentType : IMergePatchShipmentType, new()
        {
            bool bUnsaved = ((IShipmentTypeState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateShipmentType <TCreateShipmentType>());
            }
            else
            {
                return(state.ToMergePatchShipmentType <TMergePatchShipmentType>());
            }
        }
예제 #15
0
 public override IShipmentTypeAggregate GetShipmentTypeAggregate(IShipmentTypeState state)
 {
     return(new ShipmentTypeAggregate(state));
 }