Exemplo n.º 1
0
        public virtual void Initialize(IDamageTypeStateCreated stateCreated)
        {
            var aggregateId = stateCreated.DamageTypeEventId.DamageTypeId;
            var state       = new DamageTypeState();

            state.DamageTypeId = aggregateId;
            var aggregate = (DamageTypeAggregate)GetDamageTypeAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            aggregate.Apply(stateCreated);
            Persist(eventStoreAggregateId, aggregate, state);
        }
Exemplo n.º 2
0
        public virtual DamageTypeStateCreatedDto ToDamageTypeStateCreatedDto(IDamageTypeStateCreated e)
        {
            var dto = new DamageTypeStateCreatedDto();

            dto.DamageTypeEventId       = e.DamageTypeEventId;
            dto.CreatedAt               = e.CreatedAt;
            dto.CreatedBy               = e.CreatedBy;
            dto.CommandId               = e.CommandId;
            dto.Description             = e.Description;
            dto.SequenceId              = e.SequenceId;
            dto.DefaultHandlingMethodId = e.DefaultHandlingMethodId;
            dto.Active = e.Active;
            return(dto);
        }
Exemplo n.º 3
0
        public virtual void When(IDamageTypeStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.Description = e.Description;

            this.SequenceId = e.SequenceId;

            this.DefaultHandlingMethodId = e.DefaultHandlingMethodId;

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

            this.Deleted = false;

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;
        }
Exemplo n.º 4
0
        protected virtual IDamageTypeStateCreated Map(ICreateDamageType c)
        {
            var stateEventId          = new DamageTypeEventId(c.DamageTypeId, c.Version);
            IDamageTypeStateCreated e = NewDamageTypeStateCreated(stateEventId);

            e.Description             = c.Description;
            e.SequenceId              = c.SequenceId;
            e.DefaultHandlingMethodId = c.DefaultHandlingMethodId;
            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);
        }
Exemplo n.º 5
0
 void IDamageTypeState.When(IDamageTypeStateCreated e)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 6
0
        public virtual void Create(ICreateDamageType c)
        {
            IDamageTypeStateCreated e = Map(c);

            Apply(e);
        }