public virtual void Initialize(IProductStateCreated stateCreated) { var aggregateId = stateCreated.ProductEventId.ProductId; var state = new ProductState(); state.ProductId = aggregateId; var aggregate = (ProductAggregate)GetProductAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); aggregate.Apply(stateCreated); Persist(eventStoreAggregateId, aggregate, state); }
public virtual void When(IProductStateCreated e) { ThrowOnWrongEvent(e); this.ProductTypeId = e.ProductTypeId; this.PrimaryProductCategoryId = e.PrimaryProductCategoryId; this.ManufacturerPartyId = e.ManufacturerPartyId; this.FacilityId = e.FacilityId; this.IntroductionDate = e.IntroductionDate; this.ReleaseDate = e.ReleaseDate; this.SupportDiscontinuationDate = e.SupportDiscontinuationDate; this.SalesDiscontinuationDate = e.SalesDiscontinuationDate; this.SalesDiscWhenNotAvail = e.SalesDiscWhenNotAvail; this.InternalName = e.InternalName; this.BrandName = e.BrandName; this.Comments = e.Comments; this.ProductName = e.ProductName; this.Description = e.Description; this.PriceDetailText = e.PriceDetailText; this.SmallImageUrl = e.SmallImageUrl; this.MediumImageUrl = e.MediumImageUrl; this.LargeImageUrl = e.LargeImageUrl; this.DetailImageUrl = e.DetailImageUrl; this.OriginalImageUrl = e.OriginalImageUrl; this.DetailScreen = e.DetailScreen; this.InventoryMessage = e.InventoryMessage; this.InventoryItemTypeId = e.InventoryItemTypeId; this.RequireInventory = e.RequireInventory; this.QuantityUomId = e.QuantityUomId; this.QuantityIncluded = e.QuantityIncluded; this.PiecesIncluded = e.PiecesIncluded; this.RequireAmount = e.RequireAmount; this.FixedAmount = e.FixedAmount; this.AmountUomTypeId = e.AmountUomTypeId; this.WeightUomId = e.WeightUomId; this.ShippingWeight = e.ShippingWeight; this.ProductWeight = e.ProductWeight; this.HeightUomId = e.HeightUomId; this.ProductHeight = e.ProductHeight; this.ShippingHeight = e.ShippingHeight; this.WidthUomId = e.WidthUomId; this.ProductWidth = e.ProductWidth; this.ShippingWidth = e.ShippingWidth; this.DepthUomId = e.DepthUomId; this.ProductDepth = e.ProductDepth; this.ShippingDepth = e.ShippingDepth; this.DiameterUomId = e.DiameterUomId; this.ProductDiameter = e.ProductDiameter; this.ProductRating = e.ProductRating; this.RatingTypeEnum = e.RatingTypeEnum; this.Returnable = e.Returnable; this.Taxable = e.Taxable; this.ChargeShipping = e.ChargeShipping; this.AutoCreateKeywords = e.AutoCreateKeywords; this.IncludeInPromotions = e.IncludeInPromotions; this.IsVirtual = e.IsVirtual; this.IsVariant = e.IsVariant; this.VirtualVariantMethodEnum = e.VirtualVariantMethodEnum; this.InShippingBox = e.InShippingBox; this.DefaultShipmentBoxTypeId = e.DefaultShipmentBoxTypeId; this.IsSerialNumbered = (e.IsSerialNumbered != null && e.IsSerialNumbered.HasValue) ? e.IsSerialNumbered.Value : default(bool); this.IsManagedByLot = (e.IsManagedByLot != null && e.IsManagedByLot.HasValue) ? e.IsManagedByLot.Value : default(bool); this.AttributeSetId = e.AttributeSetId; this.AttributeSetInstanceId = e.AttributeSetInstanceId; this.Grade = e.Grade; this.Gsm = e.Gsm; this.CoreDiameter = e.CoreDiameter; this.OutsideDiameter = e.OutsideDiameter; this.MoisturePct = e.MoisturePct; this.RollCnt = e.RollCnt; this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool); this.CreatedBy = e.CreatedBy; this.CreatedAt = e.CreatedAt; foreach (IGoodIdentificationStateCreated innerEvent in e.GoodIdentificationEvents) { IGoodIdentificationState innerState = this.GoodIdentifications.Get(innerEvent.GlobalId.GoodIdentificationTypeId, true); innerState.Mutate(innerEvent); } }
public virtual ProductStateCreatedDto ToProductStateCreatedDto(IProductStateCreated e) { var dto = new ProductStateCreatedDto(); dto.ProductEventId = e.ProductEventId; dto.CreatedAt = e.CreatedAt; dto.CreatedBy = e.CreatedBy; dto.CommandId = e.CommandId; dto.ProductTypeId = e.ProductTypeId; dto.PrimaryProductCategoryId = e.PrimaryProductCategoryId; dto.ManufacturerPartyId = e.ManufacturerPartyId; dto.FacilityId = e.FacilityId; dto.IntroductionDate = e.IntroductionDate; dto.ReleaseDate = e.ReleaseDate; dto.SupportDiscontinuationDate = e.SupportDiscontinuationDate; dto.SalesDiscontinuationDate = e.SalesDiscontinuationDate; dto.SalesDiscWhenNotAvail = e.SalesDiscWhenNotAvail; dto.InternalName = e.InternalName; dto.BrandName = e.BrandName; dto.Comments = e.Comments; dto.ProductName = e.ProductName; dto.Description = e.Description; dto.PriceDetailText = e.PriceDetailText; dto.SmallImageUrl = e.SmallImageUrl; dto.MediumImageUrl = e.MediumImageUrl; dto.LargeImageUrl = e.LargeImageUrl; dto.DetailImageUrl = e.DetailImageUrl; dto.OriginalImageUrl = e.OriginalImageUrl; dto.DetailScreen = e.DetailScreen; dto.InventoryMessage = e.InventoryMessage; dto.InventoryItemTypeId = e.InventoryItemTypeId; dto.RequireInventory = e.RequireInventory; dto.QuantityUomId = e.QuantityUomId; dto.QuantityIncluded = e.QuantityIncluded; dto.PiecesIncluded = e.PiecesIncluded; dto.RequireAmount = e.RequireAmount; dto.FixedAmount = e.FixedAmount; dto.AmountUomTypeId = e.AmountUomTypeId; dto.WeightUomId = e.WeightUomId; dto.ShippingWeight = e.ShippingWeight; dto.ProductWeight = e.ProductWeight; dto.HeightUomId = e.HeightUomId; dto.ProductHeight = e.ProductHeight; dto.ShippingHeight = e.ShippingHeight; dto.WidthUomId = e.WidthUomId; dto.ProductWidth = e.ProductWidth; dto.ShippingWidth = e.ShippingWidth; dto.DepthUomId = e.DepthUomId; dto.ProductDepth = e.ProductDepth; dto.ShippingDepth = e.ShippingDepth; dto.DiameterUomId = e.DiameterUomId; dto.ProductDiameter = e.ProductDiameter; dto.ProductRating = e.ProductRating; dto.RatingTypeEnum = e.RatingTypeEnum; dto.Returnable = e.Returnable; dto.Taxable = e.Taxable; dto.ChargeShipping = e.ChargeShipping; dto.AutoCreateKeywords = e.AutoCreateKeywords; dto.IncludeInPromotions = e.IncludeInPromotions; dto.IsVirtual = e.IsVirtual; dto.IsVariant = e.IsVariant; dto.VirtualVariantMethodEnum = e.VirtualVariantMethodEnum; dto.InShippingBox = e.InShippingBox; dto.DefaultShipmentBoxTypeId = e.DefaultShipmentBoxTypeId; dto.IsSerialNumbered = e.IsSerialNumbered; dto.IsManagedByLot = e.IsManagedByLot; dto.AttributeSetId = e.AttributeSetId; dto.AttributeSetInstanceId = e.AttributeSetInstanceId; dto.Active = e.Active; var goodIdentificationEvents = new List <GoodIdentificationStateCreatedDto>(); foreach (var ee in e.GoodIdentificationEvents) { GoodIdentificationStateCreatedDto eeDto = GoodIdentificationStateEventDtoConverter.ToGoodIdentificationStateCreatedDto(ee); goodIdentificationEvents.Add(eeDto); } dto.GoodIdentificationEvents = goodIdentificationEvents.ToArray(); return(dto); }
protected virtual IProductStateCreated Map(ICreateProduct c) { var stateEventId = new ProductEventId(c.ProductId, c.Version); IProductStateCreated e = NewProductStateCreated(stateEventId); e.ProductTypeId = c.ProductTypeId; e.PrimaryProductCategoryId = c.PrimaryProductCategoryId; e.ManufacturerPartyId = c.ManufacturerPartyId; e.FacilityId = c.FacilityId; e.IntroductionDate = c.IntroductionDate; e.ReleaseDate = c.ReleaseDate; e.SupportDiscontinuationDate = c.SupportDiscontinuationDate; e.SalesDiscontinuationDate = c.SalesDiscontinuationDate; e.SalesDiscWhenNotAvail = c.SalesDiscWhenNotAvail; e.InternalName = c.InternalName; e.BrandName = c.BrandName; e.Comments = c.Comments; e.ProductName = c.ProductName; e.Description = c.Description; e.PriceDetailText = c.PriceDetailText; e.SmallImageUrl = c.SmallImageUrl; e.MediumImageUrl = c.MediumImageUrl; e.LargeImageUrl = c.LargeImageUrl; e.DetailImageUrl = c.DetailImageUrl; e.OriginalImageUrl = c.OriginalImageUrl; e.DetailScreen = c.DetailScreen; e.InventoryMessage = c.InventoryMessage; e.InventoryItemTypeId = c.InventoryItemTypeId; e.RequireInventory = c.RequireInventory; e.QuantityUomId = c.QuantityUomId; e.QuantityIncluded = c.QuantityIncluded; e.PiecesIncluded = c.PiecesIncluded; e.RequireAmount = c.RequireAmount; e.FixedAmount = c.FixedAmount; e.AmountUomTypeId = c.AmountUomTypeId; e.WeightUomId = c.WeightUomId; e.ShippingWeight = c.ShippingWeight; e.ProductWeight = c.ProductWeight; e.HeightUomId = c.HeightUomId; e.ProductHeight = c.ProductHeight; e.ShippingHeight = c.ShippingHeight; e.WidthUomId = c.WidthUomId; e.ProductWidth = c.ProductWidth; e.ShippingWidth = c.ShippingWidth; e.DepthUomId = c.DepthUomId; e.ProductDepth = c.ProductDepth; e.ShippingDepth = c.ShippingDepth; e.DiameterUomId = c.DiameterUomId; e.ProductDiameter = c.ProductDiameter; e.ProductRating = c.ProductRating; e.RatingTypeEnum = c.RatingTypeEnum; e.Returnable = c.Returnable; e.Taxable = c.Taxable; e.ChargeShipping = c.ChargeShipping; e.AutoCreateKeywords = c.AutoCreateKeywords; e.IncludeInPromotions = c.IncludeInPromotions; e.IsVirtual = c.IsVirtual; e.IsVariant = c.IsVariant; e.VirtualVariantMethodEnum = c.VirtualVariantMethodEnum; e.InShippingBox = c.InShippingBox; e.DefaultShipmentBoxTypeId = c.DefaultShipmentBoxTypeId; e.IsSerialNumbered = c.IsSerialNumbered; e.IsManagedByLot = c.IsManagedByLot; e.AttributeSetId = c.AttributeSetId; e.AttributeSetInstanceId = c.AttributeSetInstanceId; e.Active = c.Active; e.CommandId = c.CommandId; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); var version = c.Version; foreach (ICreateGoodIdentification innerCommand in c.GoodIdentifications) { ThrowOnInconsistentCommands(c, innerCommand); IGoodIdentificationStateCreated innerEvent = MapCreate(innerCommand, c, version, _state); e.AddGoodIdentificationEvent(innerEvent); } return(e); }
public virtual void Create(ICreateProduct c) { IProductStateCreated e = Map(c); Apply(e); }