Esempio n. 1
0
        public virtual void Initialize(IUomStateCreated stateCreated)
        {
            var aggregateId = stateCreated.UomEventId.UomId;
            var state       = new UomState();

            state.UomId = aggregateId;
            var aggregate = (UomAggregate)GetUomAggregate(state);

            var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId);

            aggregate.Apply(stateCreated);
            Persist(eventStoreAggregateId, aggregate, state);
        }
Esempio n. 2
0
        public virtual UomStateCreatedDto ToUomStateCreatedDto(IUomStateCreated e)
        {
            var dto = new UomStateCreatedDto();

            dto.UomEventId   = e.UomEventId;
            dto.CreatedAt    = e.CreatedAt;
            dto.CreatedBy    = e.CreatedBy;
            dto.CommandId    = e.CommandId;
            dto.UomTypeId    = e.UomTypeId;
            dto.Abbreviation = e.Abbreviation;
            dto.Description  = e.Description;
            dto.Active       = e.Active;
            return(dto);
        }
Esempio n. 3
0
        public virtual void When(IUomStateCreated e)
        {
            ThrowOnWrongEvent(e);
            this.UomTypeId = e.UomTypeId;

            this.Abbreviation = e.Abbreviation;

            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;
        }
Esempio n. 4
0
        protected virtual IUomStateCreated Map(ICreateUom c)
        {
            var stateEventId   = new UomEventId(c.UomId, c.Version);
            IUomStateCreated e = NewUomStateCreated(stateEventId);

            e.UomTypeId    = c.UomTypeId;
            e.Abbreviation = c.Abbreviation;
            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);
        }
Esempio n. 5
0
        public virtual void Create(ICreateUom c)
        {
            IUomStateCreated e = Map(c);

            Apply(e);
        }
Esempio n. 6
0
 void IUomState.When(IUomStateCreated e)
 {
     throw new NotSupportedException();
 }