public virtual void Initialize(IDocumentTypeStateCreated stateCreated)
        {
            var aggregateId = stateCreated.DocumentTypeEventId.DocumentTypeId;
            var state       = new DocumentTypeState();

            state.DocumentTypeId = aggregateId;
            var aggregate = (DocumentTypeAggregate)GetDocumentTypeAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            aggregate.Apply(stateCreated);
            Persist(eventStoreAggregateId, aggregate, state);
        }
Example #2
0
        public virtual DocumentTypeStateCreatedDto ToDocumentTypeStateCreatedDto(IDocumentTypeStateCreated e)
        {
            var dto = new DocumentTypeStateCreatedDto();

            dto.DocumentTypeEventId  = e.DocumentTypeEventId;
            dto.CreatedAt            = e.CreatedAt;
            dto.CreatedBy            = e.CreatedBy;
            dto.CommandId            = e.CommandId;
            dto.Description          = e.Description;
            dto.ParentDocumentTypeId = e.ParentDocumentTypeId;
            dto.Active = e.Active;
            return(dto);
        }
Example #3
0
        public virtual void When(IDocumentTypeStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.Description = e.Description;

            this.ParentDocumentTypeId = e.ParentDocumentTypeId;

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

            this.Deleted = false;

            this.CreatedBy = e.CreatedBy;
            this.CreatedAt = e.CreatedAt;
        }
Example #4
0
        protected virtual IDocumentTypeStateCreated Map(ICreateDocumentType c)
        {
            var stateEventId            = new DocumentTypeEventId(c.DocumentTypeId, c.Version);
            IDocumentTypeStateCreated e = NewDocumentTypeStateCreated(stateEventId);

            e.Description          = c.Description;
            e.ParentDocumentTypeId = c.ParentDocumentTypeId;
            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);
        }
Example #5
0
        public virtual void Create(ICreateDocumentType c)
        {
            IDocumentTypeStateCreated e = Map(c);

            Apply(e);
        }
 void IDocumentTypeState.When(IDocumentTypeStateCreated e)
 {
     throw new NotSupportedException();
 }