Ejemplo n.º 1
0
        public static TCreateFacility ToCreateFacility <TCreateFacility>(this IFacilityState state)
            where TCreateFacility : ICreateFacility, new()
        {
            var cmd = new TCreateFacility();

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

            cmd.FacilityId                 = state.FacilityId;
            cmd.FacilityTypeId             = state.FacilityTypeId;
            cmd.ParentFacilityId           = state.ParentFacilityId;
            cmd.OwnerPartyId               = state.OwnerPartyId;
            cmd.DefaultInventoryItemTypeId = state.DefaultInventoryItemTypeId;
            cmd.FacilityName               = state.FacilityName;
            cmd.PrimaryFacilityGroupId     = state.PrimaryFacilityGroupId;
            cmd.OldSquareFootage           = state.OldSquareFootage;
            cmd.FacilitySize               = state.FacilitySize;
            cmd.FacilitySizeUomId          = state.FacilitySizeUomId;
            cmd.ProductStoreId             = state.ProductStoreId;
            cmd.DefaultDaysToShip          = state.DefaultDaysToShip;
            cmd.OpenedDate                 = state.OpenedDate;
            cmd.ClosedDate                 = state.ClosedDate;
            cmd.Description                = state.Description;
            cmd.DefaultDimensionUomId      = state.DefaultDimensionUomId;
            cmd.DefaultWeightUomId         = state.DefaultWeightUomId;
            cmd.GeoPointId                 = state.GeoPointId;
            cmd.Active = ((IFacilityStateProperties)state).Active;
            return(cmd);
        }
Ejemplo n.º 2
0
        public static TDeleteFacility ToDeleteFacility <TDeleteFacility>(this IFacilityState state)
            where TDeleteFacility : IDeleteFacility, new()
        {
            var cmd = new TDeleteFacility();

            cmd.FacilityId = state.FacilityId;
            cmd.Version    = ((IFacilityStateProperties)state).Version;

            return(cmd);
        }
        public IFacilityState Get(string id)
        {
            IFacilityState state = CurrentSession.Get <FacilityState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IFacilityState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
Ejemplo n.º 4
0
        public IFacilityState Get(string id, bool nullAllowed)
        {
            IFacilityState state = CurrentSession.Get <FacilityState> (id);

            if (!nullAllowed && state == null)
            {
                state = new FacilityState();
                (state as FacilityState).FacilityId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IFacilityState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public async Task <IFacilityState> GetAsync(string facilityId)
        {
            IFacilityState state         = null;
            var            idObj         = facilityId;
            var            uriParameters = new FacilityUriParameters();

            uriParameters.Id = idObj;

            var req = new FacilityGetRequest(uriParameters);

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

            FacilityProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToFacilityState();
            return(state);
        }
Ejemplo n.º 6
0
        public void Save(IFacilityState state)
        {
            IFacilityState s = state;

            if (ReadOnlyProxyGenerator != null)
            {
                s = ReadOnlyProxyGenerator.GetTarget <IFacilityState>(state);
            }
            CurrentSession.SaveOrUpdate(s);

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Flush();
        }
Ejemplo n.º 7
0
 public override IFacilityAggregate GetFacilityAggregate(IFacilityState state)
 {
     return(new FacilityAggregate(state));
 }
Ejemplo n.º 8
0
 public FacilityAggregate(IFacilityState state)
 {
     _state = state;
 }
Ejemplo n.º 9
0
 public FacilityStateDtoWrapper(IFacilityState state)
 {
     this._state = state;
 }
Ejemplo n.º 10
0
 public FacilityStateDtoWrapper()
 {
     this._state = new FacilityState();
 }
Ejemplo n.º 11
0
        public static TMergePatchFacility ToMergePatchFacility <TMergePatchFacility>(this IFacilityState state)
            where TMergePatchFacility : IMergePatchFacility, new()
        {
            var cmd = new TMergePatchFacility();

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

            cmd.FacilityId                 = state.FacilityId;
            cmd.FacilityTypeId             = state.FacilityTypeId;
            cmd.ParentFacilityId           = state.ParentFacilityId;
            cmd.OwnerPartyId               = state.OwnerPartyId;
            cmd.DefaultInventoryItemTypeId = state.DefaultInventoryItemTypeId;
            cmd.FacilityName               = state.FacilityName;
            cmd.PrimaryFacilityGroupId     = state.PrimaryFacilityGroupId;
            cmd.OldSquareFootage           = state.OldSquareFootage;
            cmd.FacilitySize               = state.FacilitySize;
            cmd.FacilitySizeUomId          = state.FacilitySizeUomId;
            cmd.ProductStoreId             = state.ProductStoreId;
            cmd.DefaultDaysToShip          = state.DefaultDaysToShip;
            cmd.OpenedDate                 = state.OpenedDate;
            cmd.ClosedDate                 = state.ClosedDate;
            cmd.Description                = state.Description;
            cmd.DefaultDimensionUomId      = state.DefaultDimensionUomId;
            cmd.DefaultWeightUomId         = state.DefaultWeightUomId;
            cmd.GeoPointId                 = state.GeoPointId;
            cmd.Active = ((IFacilityStateProperties)state).Active;

            if (state.FacilityTypeId == null)
            {
                cmd.IsPropertyFacilityTypeIdRemoved = true;
            }
            if (state.ParentFacilityId == null)
            {
                cmd.IsPropertyParentFacilityIdRemoved = true;
            }
            if (state.OwnerPartyId == null)
            {
                cmd.IsPropertyOwnerPartyIdRemoved = true;
            }
            if (state.DefaultInventoryItemTypeId == null)
            {
                cmd.IsPropertyDefaultInventoryItemTypeIdRemoved = true;
            }
            if (state.FacilityName == null)
            {
                cmd.IsPropertyFacilityNameRemoved = true;
            }
            if (state.PrimaryFacilityGroupId == null)
            {
                cmd.IsPropertyPrimaryFacilityGroupIdRemoved = true;
            }
            if (state.OldSquareFootage == null)
            {
                cmd.IsPropertyOldSquareFootageRemoved = true;
            }
            if (state.FacilitySize == null)
            {
                cmd.IsPropertyFacilitySizeRemoved = true;
            }
            if (state.FacilitySizeUomId == null)
            {
                cmd.IsPropertyFacilitySizeUomIdRemoved = true;
            }
            if (state.ProductStoreId == null)
            {
                cmd.IsPropertyProductStoreIdRemoved = true;
            }
            if (state.DefaultDaysToShip == null)
            {
                cmd.IsPropertyDefaultDaysToShipRemoved = true;
            }
            if (state.OpenedDate == null)
            {
                cmd.IsPropertyOpenedDateRemoved = true;
            }
            if (state.ClosedDate == null)
            {
                cmd.IsPropertyClosedDateRemoved = true;
            }
            if (state.Description == null)
            {
                cmd.IsPropertyDescriptionRemoved = true;
            }
            if (state.DefaultDimensionUomId == null)
            {
                cmd.IsPropertyDefaultDimensionUomIdRemoved = true;
            }
            if (state.DefaultWeightUomId == null)
            {
                cmd.IsPropertyDefaultWeightUomIdRemoved = true;
            }
            if (state.GeoPointId == null)
            {
                cmd.IsPropertyGeoPointIdRemoved = true;
            }
            return(cmd);
        }
Ejemplo n.º 12
0
        public static IFacilityCommand ToCreateOrMergePatchFacility <TCreateFacility, TMergePatchFacility>(this IFacilityState state)
            where TCreateFacility : ICreateFacility, new()
            where TMergePatchFacility : IMergePatchFacility, new()
        {
            bool bUnsaved = ((IFacilityState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateFacility <TCreateFacility>());
            }
            else
            {
                return(state.ToMergePatchFacility <TMergePatchFacility>());
            }
        }
Ejemplo n.º 13
0
        protected bool IsRepeatedCommand(IFacilityCommand command, IEventStoreAggregateId eventStoreAggregateId, IFacilityState state)
        {
            bool repeated = false;

            if (((IFacilityStateProperties)state).Version > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(IFacilityEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
Ejemplo n.º 14
0
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, IFacilityAggregate aggregate, IFacilityState state)
 {
     EventStore.AppendEvents(eventStoreAggregateId, ((IFacilityStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); });
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <IFacilityAggregate, IFacilityState>(aggregate, state, aggregate.Changes));
     }
 }
Ejemplo n.º 15
0
 public abstract IFacilityAggregate GetFacilityAggregate(IFacilityState state);