Esempio n. 1
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 6
0
        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();
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
 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));
     }
 }
Esempio n. 10
0
 public abstract IUomAggregate GetUomAggregate(IUomState state);
Esempio n. 11
0
 public UomAggregate(IUomState state)
 {
     _state = state;
 }
Esempio n. 12
0
 public UomStateDtoWrapper(IUomState state)
 {
     this._state = state;
 }
Esempio n. 13
0
 public UomStateDtoWrapper()
 {
     this._state = new UomState();
 }
Esempio n. 14
0
 public override IUomAggregate GetUomAggregate(IUomState state)
 {
     return(new UomAggregate(state));
 }
Esempio n. 15
0
        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>());
            }
        }