Exemplo n.º 1
0
        public virtual void When(IPartyRoleStateCreated e)
        {
            ThrowOnWrongEvent(e);
            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.º 2
0
        public virtual PartyRoleStateCreatedDto ToPartyRoleStateCreatedDto(IPartyRoleStateCreated e)
        {
            var dto = new PartyRoleStateCreatedDto();

            dto.PartyRoleEventId = e.PartyRoleEventId;
            dto.CreatedAt        = e.CreatedAt;
            dto.CreatedBy        = e.CreatedBy;
            dto.CommandId        = e.CommandId;
            dto.Active           = e.Active;
            return(dto);
        }
Exemplo n.º 3
0
        public virtual void Initialize(IPartyRoleStateCreated stateCreated)
        {
            var aggregateId = stateCreated.PartyRoleEventId.PartyRoleId;
            var state       = new PartyRoleState();

            state.PartyRoleId = aggregateId;
            var aggregate = (PartyRoleAggregate)GetPartyRoleAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            aggregate.Apply(stateCreated);
            Persist(eventStoreAggregateId, aggregate, state);
        }
Exemplo n.º 4
0
        protected virtual IPartyRoleStateCreated Map(ICreatePartyRole c)
        {
            var stateEventId         = new PartyRoleEventId(c.PartyRoleId, c.Version);
            IPartyRoleStateCreated e = NewPartyRoleStateCreated(stateEventId);

            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
        public virtual void Create(ICreatePartyRole c)
        {
            IPartyRoleStateCreated e = Map(c);

            Apply(e);
        }
Exemplo n.º 6
0
 void IPartyRoleState.When(IPartyRoleStateCreated e)
 {
     throw new NotSupportedException();
 }