public static TMergePatchRoleType ToMergePatchRoleType <TMergePatchRoleType>(this IRoleTypeState state)
            where TMergePatchRoleType : IMergePatchRoleType, new()
        {
            var cmd = new TMergePatchRoleType();

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

            cmd.RoleTypeId   = state.RoleTypeId;
            cmd.ParentTypeId = state.ParentTypeId;
            cmd.HasTable     = state.HasTable;
            cmd.Description  = state.Description;
            cmd.Active       = ((IRoleTypeStateProperties)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 IRoleTypeState Get(string id)
        {
            IRoleTypeState state = CurrentSession.Get <RoleTypeState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IRoleTypeState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public static TDeleteRoleType ToDeleteRoleType <TDeleteRoleType>(this IRoleTypeState state)
            where TDeleteRoleType : IDeleteRoleType, new()
        {
            var cmd = new TDeleteRoleType();

            cmd.RoleTypeId = state.RoleTypeId;
            cmd.Version    = ((IRoleTypeStateProperties)state).Version;

            return(cmd);
        }
        public static TCreateRoleType ToCreateRoleType <TCreateRoleType>(this IRoleTypeState state)
            where TCreateRoleType : ICreateRoleType, new()
        {
            var cmd = new TCreateRoleType();

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

            cmd.RoleTypeId   = state.RoleTypeId;
            cmd.ParentTypeId = state.ParentTypeId;
            cmd.HasTable     = state.HasTable;
            cmd.Description  = state.Description;
            cmd.Active       = ((IRoleTypeStateProperties)state).Active;
            return(cmd);
        }
Exemple #5
0
        public IRoleTypeState Get(string id, bool nullAllowed)
        {
            IRoleTypeState state = CurrentSession.Get <RoleTypeState> (id);

            if (!nullAllowed && state == null)
            {
                state = new RoleTypeState();
                (state as RoleTypeState).RoleTypeId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IRoleTypeState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
Exemple #6
0
        public async Task <IRoleTypeState> GetAsync(string roleTypeId)
        {
            IRoleTypeState state         = null;
            var            idObj         = roleTypeId;
            var            uriParameters = new RoleTypeUriParameters();

            uriParameters.Id = idObj;

            var req = new RoleTypeGetRequest(uriParameters);

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

            RoleTypeProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToRoleTypeState();
            return(state);
        }
Exemple #7
0
        public void Save(IRoleTypeState state)
        {
            IRoleTypeState s = state;

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

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Flush();
        }
        protected bool IsRepeatedCommand(IRoleTypeCommand command, IEventStoreAggregateId eventStoreAggregateId, IRoleTypeState state)
        {
            bool repeated = false;

            if (((IRoleTypeStateProperties)state).Version > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(IRoleTypeEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, IRoleTypeAggregate aggregate, IRoleTypeState state)
 {
     EventStore.AppendEvents(eventStoreAggregateId, ((IRoleTypeStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); });
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <IRoleTypeAggregate, IRoleTypeState>(aggregate, state, aggregate.Changes));
     }
 }
 public abstract IRoleTypeAggregate GetRoleTypeAggregate(IRoleTypeState state);
        public static IRoleTypeCommand ToCreateOrMergePatchRoleType <TCreateRoleType, TMergePatchRoleType>(this IRoleTypeState state)
            where TCreateRoleType : ICreateRoleType, new()
            where TMergePatchRoleType : IMergePatchRoleType, new()
        {
            bool bUnsaved = ((IRoleTypeState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateRoleType <TCreateRoleType>());
            }
            else
            {
                return(state.ToMergePatchRoleType <TMergePatchRoleType>());
            }
        }
Exemple #12
0
 public override IRoleTypeAggregate GetRoleTypeAggregate(IRoleTypeState state)
 {
     return(new RoleTypeAggregate(state));
 }
 public RoleTypeStateDtoWrapper(IRoleTypeState state)
 {
     this._state = state;
 }
 public RoleTypeStateDtoWrapper()
 {
     this._state = new RoleTypeState();
 }
Exemple #15
0
 public RoleTypeAggregate(IRoleTypeState state)
 {
     _state = state;
 }