Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public static CreateProduct ToCreateProduct(this ProductState state)
 {
     return(state.ToCreateProduct <CreateProduct, CreateGoodIdentification>());
 }
Exemplo n.º 3
0
 public static MergePatchProduct ToMergePatchProduct(this ProductState state)
 {
     return(state.ToMergePatchProduct <MergePatchProduct, CreateGoodIdentification, MergePatchGoodIdentification>());
 }
Exemplo n.º 4
0
 public static DeleteProduct ToDeleteProduct(this ProductState state)
 {
     return(state.ToDeleteProduct <DeleteProduct>());
 }
Exemplo n.º 5
0
 public static IProductCommand ToCreateOrMergePatchProduct(this ProductState state)
 {
     return(state.ToCreateOrMergePatchProduct <CreateProduct, MergePatchProduct, CreateGoodIdentification, MergePatchGoodIdentification>());
 }
Exemplo n.º 6
0
        public virtual IProductState ToProductState()
        {
            var state = new ProductState(true);

            state.ProductId                  = this.ProductId;
            state.ProductTypeId              = this.ProductTypeId;
            state.PrimaryProductCategoryId   = this.PrimaryProductCategoryId;
            state.ManufacturerPartyId        = this.ManufacturerPartyId;
            state.FacilityId                 = this.FacilityId;
            state.IntroductionDate           = this.IntroductionDate;
            state.ReleaseDate                = this.ReleaseDate;
            state.SupportDiscontinuationDate = this.SupportDiscontinuationDate;
            state.SalesDiscontinuationDate   = this.SalesDiscontinuationDate;
            state.SalesDiscWhenNotAvail      = this.SalesDiscWhenNotAvail;
            state.InternalName               = this.InternalName;
            state.BrandName                  = this.BrandName;
            state.Comments                 = this.Comments;
            state.ProductName              = this.ProductName;
            state.Description              = this.Description;
            state.PriceDetailText          = this.PriceDetailText;
            state.SmallImageUrl            = this.SmallImageUrl;
            state.MediumImageUrl           = this.MediumImageUrl;
            state.LargeImageUrl            = this.LargeImageUrl;
            state.DetailImageUrl           = this.DetailImageUrl;
            state.OriginalImageUrl         = this.OriginalImageUrl;
            state.DetailScreen             = this.DetailScreen;
            state.InventoryMessage         = this.InventoryMessage;
            state.InventoryItemTypeId      = this.InventoryItemTypeId;
            state.RequireInventory         = this.RequireInventory;
            state.QuantityUomId            = this.QuantityUomId;
            state.QuantityIncluded         = this.QuantityIncluded;
            state.PiecesIncluded           = this.PiecesIncluded;
            state.RequireAmount            = this.RequireAmount;
            state.FixedAmount              = this.FixedAmount;
            state.AmountUomTypeId          = this.AmountUomTypeId;
            state.WeightUomId              = this.WeightUomId;
            state.ShippingWeight           = this.ShippingWeight;
            state.ProductWeight            = this.ProductWeight;
            state.HeightUomId              = this.HeightUomId;
            state.ProductHeight            = this.ProductHeight;
            state.ShippingHeight           = this.ShippingHeight;
            state.WidthUomId               = this.WidthUomId;
            state.ProductWidth             = this.ProductWidth;
            state.ShippingWidth            = this.ShippingWidth;
            state.DepthUomId               = this.DepthUomId;
            state.ProductDepth             = this.ProductDepth;
            state.ShippingDepth            = this.ShippingDepth;
            state.DiameterUomId            = this.DiameterUomId;
            state.ProductDiameter          = this.ProductDiameter;
            state.ProductRating            = this.ProductRating;
            state.RatingTypeEnum           = this.RatingTypeEnum;
            state.Returnable               = this.Returnable;
            state.Taxable                  = this.Taxable;
            state.ChargeShipping           = this.ChargeShipping;
            state.AutoCreateKeywords       = this.AutoCreateKeywords;
            state.IncludeInPromotions      = this.IncludeInPromotions;
            state.IsVirtual                = this.IsVirtual;
            state.IsVariant                = this.IsVariant;
            state.VirtualVariantMethodEnum = this.VirtualVariantMethodEnum;
            state.InShippingBox            = this.InShippingBox;
            state.DefaultShipmentBoxTypeId = this.DefaultShipmentBoxTypeId;
            if (this.IsSerialNumbered != null && this.IsSerialNumbered.HasValue)
            {
                state.IsSerialNumbered = this.IsSerialNumbered.Value;
            }
            if (this.IsManagedByLot != null && this.IsManagedByLot.HasValue)
            {
                state.IsManagedByLot = this.IsManagedByLot.Value;
            }
            state.AttributeSetId         = this.AttributeSetId;
            state.AttributeSetInstanceId = this.AttributeSetInstanceId;
            if (this.Active != null && this.Active.HasValue)
            {
                state.Active = this.Active.Value;
            }
            if (this.Version != null && this.Version.HasValue)
            {
                state.Version = this.Version.Value;
            }
            state.CreatedBy = this.CreatedBy;
            if (this.CreatedAt != null && this.CreatedAt.HasValue)
            {
                state.CreatedAt = this.CreatedAt.Value;
            }
            state.UpdatedBy = this.UpdatedBy;
            if (this.UpdatedAt != null && this.UpdatedAt.HasValue)
            {
                state.UpdatedAt = this.UpdatedAt.Value;
            }
            if (this.GoodIdentifications != null)
            {
                foreach (var s in this.GoodIdentifications)
                {
                    state.GoodIdentifications.AddToSave(s.ToGoodIdentificationState());
                }
            }
            ;

            return(state);
        }