Ejemplo n.º 1
0
        public virtual RoleStateCreatedDto ToRoleStateCreatedDto(IRoleStateCreated e)
        {
            var dto = new RoleStateCreatedDto();

            dto.RoleEventId = e.RoleEventId;
            dto.CreatedAt   = e.CreatedAt;
            dto.CreatedBy   = e.CreatedBy;
            dto.CommandId   = e.CommandId;
            dto.Name        = e.Name;
            dto.Description = e.Description;
            dto.Active      = e.Active;
            return(dto);
        }
Ejemplo n.º 2
0
        public virtual void Initialize(IRoleStateCreated stateCreated)
        {
            var aggregateId = stateCreated.RoleEventId.RoleId;
            var state       = new RoleState();

            state.RoleId = aggregateId;
            var aggregate = (RoleAggregate)GetRoleAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            aggregate.Apply(stateCreated);
            Persist(eventStoreAggregateId, aggregate, state);
        }
Ejemplo n.º 3
0
        public virtual void When(IRoleStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.Name = e.Name;

            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;
        }
Ejemplo n.º 4
0
        protected virtual IRoleStateCreated Map(ICreateRole c)
        {
            var stateEventId    = new RoleStateEventId(c.RoleId, c.Version);
            IRoleStateCreated e = NewRoleStateCreated(stateEventId);

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


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


            return(e);
        }
Ejemplo n.º 5
0
        protected virtual IRoleStateCreated Map(ICreateRole c)
        {
            var stateEventId    = new RoleEventId(c.RoleId, c.Version);
            IRoleStateCreated e = NewRoleStateCreated(stateEventId);

            e.Name        = c.Name;
            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);
        }
Ejemplo n.º 6
0
        public virtual void Create(ICreateRole c)
        {
            IRoleStateCreated e = Map(c);

            Apply(e);
        }
Ejemplo n.º 7
0
 void IRoleState.When(IRoleStateCreated e)
 {
     throw new NotSupportedException();
 }