public virtual void Initialize(IPermissionStateCreated stateCreated)
        {
            var aggregateId = stateCreated.PermissionEventId.PermissionId;
            var state       = new PermissionState();

            state.PermissionId = aggregateId;
            var aggregate = (PermissionAggregate)GetPermissionAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            aggregate.Apply(stateCreated);
            Persist(eventStoreAggregateId, aggregate, state);
        }
Beispiel #2
0
        public virtual PermissionStateCreatedDto ToPermissionStateCreatedDto(IPermissionStateCreated e)
        {
            var dto = new PermissionStateCreatedDto();

            dto.PermissionEventId = e.PermissionEventId;
            dto.CreatedAt         = e.CreatedAt;
            dto.CreatedBy         = e.CreatedBy;
            dto.CommandId         = e.CommandId;
            dto.Name = e.Name;
            dto.ParentPermissionId = e.ParentPermissionId;
            dto.Description        = e.Description;
            dto.Active             = e.Active;
            return(dto);
        }
Beispiel #3
0
        public virtual void When(IPermissionStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.Name = e.Name;

            this.ParentPermissionId = e.ParentPermissionId;

            this.Description = e.Description;

            this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool);

            this.Deleted = false;

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;
        }
Beispiel #4
0
        protected virtual IPermissionStateCreated Map(ICreatePermission c)
        {
            var stateEventId          = new PermissionStateEventId(c.PermissionId, c.Version);
            IPermissionStateCreated e = NewPermissionStateCreated(stateEventId);

            e.Name = c.Name;
            e.ParentPermissionId = c.ParentPermissionId;
            e.Description        = c.Description;
            e.Active             = c.Active;
            ReflectUtils.CopyPropertyValue("CommandId", c, e);


            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = DateTime.Now;
            var version = c.Version;


            return(e);
        }
Beispiel #5
0
        protected virtual IPermissionStateCreated Map(ICreatePermission c)
        {
            var stateEventId          = new PermissionEventId(c.PermissionId, c.Version);
            IPermissionStateCreated e = NewPermissionStateCreated(stateEventId);

            e.Name = c.Name;
            e.ParentPermissionId = c.ParentPermissionId;
            e.Description        = c.Description;
            e.Active             = c.Active;
            e.CommandId          = c.CommandId;


            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>();
            var version = c.Version;


            return(e);
        }
Beispiel #6
0
        public virtual void Create(ICreatePermission c)
        {
            IPermissionStateCreated e = Map(c);

            Apply(e);
        }
 void IPermissionState.When(IPermissionStateCreated e)
 {
     throw new NotSupportedException();
 }