예제 #1
0
        public IProductCategoryState Get(string id)
        {
            IProductCategoryState state = CurrentSession.Get <ProductCategoryState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IProductCategoryState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public IProductCategoryState Get(string id, bool nullAllowed)
        {
            IProductCategoryState state = CurrentSession.Get <ProductCategoryState> (id);

            if (!nullAllowed && state == null)
            {
                state = new ProductCategoryState();
                (state as ProductCategoryState).ProductCategoryId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IProductCategoryState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
예제 #3
0
        public virtual IEnumerable <IProductCategoryState> GetChildProductCategories(string productCategoryId)
        {
            IProductCategoryState productCategoryState = CurrentSession.Get <ProductCategoryState>(productCategoryId);

            if (productCategoryState == null)
            {
                return(null);
            }
            var criteria        = CurrentSession.CreateCriteria <ProductCategoryState>();
            var partIdCondition = NHibernateRestrictions.Conjunction()
                                  .Add(NHibernateRestrictions.Eq("PrimaryParentCategoryId", productCategoryState.ProductCategoryId))
            ;

            return(criteria.Add(partIdCondition).List <ProductCategoryState>());
        }
        public async Task <IProductCategoryState> GetAsync(string productCategoryId)
        {
            IProductCategoryState state = null;
            var idObj         = productCategoryId;
            var uriParameters = new ProductCategoryUriParameters();

            uriParameters.Id = idObj;

            var req = new ProductCategoryGetRequest(uriParameters);

            var resp = await _ramlClient.ProductCategory.Get(req);

            ProductCategoryProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToProductCategoryState();
            return(state);
        }
        public void Save(IProductCategoryState state)
        {
            IProductCategoryState s = state;

            if (ReadOnlyProxyGenerator != null)
            {
                s = ReadOnlyProxyGenerator.GetTarget <IProductCategoryState>(state);
            }
            CurrentSession.SaveOrUpdate(s);

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
            CurrentSession.Flush();
        }
예제 #6
0
 public ProductCategoryAggregate(IProductCategoryState state)
 {
     _state = state;
 }
예제 #7
0
 public override IProductCategoryAggregate GetProductCategoryAggregate(IProductCategoryState state)
 {
     return(new ProductCategoryAggregate(state));
 }
예제 #8
0
 public ProductCategoryStateDtoWrapper(IProductCategoryState state)
 {
     this._state = state;
 }
예제 #9
0
 public ProductCategoryStateDtoWrapper()
 {
     this._state = new ProductCategoryState();
 }
예제 #10
0
        protected bool IsRepeatedCommand(IProductCategoryCommand command, IEventStoreAggregateId eventStoreAggregateId, IProductCategoryState state)
        {
            bool repeated = false;

            if (((IProductCategoryStateProperties)state).Version > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(IProductCategoryEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
예제 #11
0
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, IProductCategoryAggregate aggregate, IProductCategoryState state)
 {
     EventStore.AppendEvents(eventStoreAggregateId, ((IProductCategoryStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); });
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <IProductCategoryAggregate, IProductCategoryState>(aggregate, state, aggregate.Changes));
     }
 }
예제 #12
0
 public abstract IProductCategoryAggregate GetProductCategoryAggregate(IProductCategoryState state);
예제 #13
0
        public static TCreateProductCategory ToCreateProductCategory <TCreateProductCategory>(this IProductCategoryState state)
            where TCreateProductCategory : ICreateProductCategory, new()
        {
            var cmd = new TCreateProductCategory();

            cmd.Version = ((IProductCategoryStateProperties)state).Version;

            cmd.ProductCategoryId       = state.ProductCategoryId;
            cmd.ProductCategoryTypeId   = state.ProductCategoryTypeId;
            cmd.PrimaryParentCategoryId = state.PrimaryParentCategoryId;
            cmd.CategoryName            = state.CategoryName;
            cmd.Description             = state.Description;
            cmd.CategoryImageUrl        = state.CategoryImageUrl;
            cmd.DetailScreen            = state.DetailScreen;
            cmd.ShowInSelect            = state.ShowInSelect;
            cmd.AttributeSetId          = state.AttributeSetId;
            cmd.Active = ((IProductCategoryStateProperties)state).Active;
            return(cmd);
        }
예제 #14
0
        public static TMergePatchProductCategory ToMergePatchProductCategory <TMergePatchProductCategory>(this IProductCategoryState state)
            where TMergePatchProductCategory : IMergePatchProductCategory, new()
        {
            var cmd = new TMergePatchProductCategory();

            cmd.Version = ((IProductCategoryStateProperties)state).Version;

            cmd.ProductCategoryId       = state.ProductCategoryId;
            cmd.ProductCategoryTypeId   = state.ProductCategoryTypeId;
            cmd.PrimaryParentCategoryId = state.PrimaryParentCategoryId;
            cmd.CategoryName            = state.CategoryName;
            cmd.Description             = state.Description;
            cmd.CategoryImageUrl        = state.CategoryImageUrl;
            cmd.DetailScreen            = state.DetailScreen;
            cmd.ShowInSelect            = state.ShowInSelect;
            cmd.AttributeSetId          = state.AttributeSetId;
            cmd.Active = ((IProductCategoryStateProperties)state).Active;

            if (state.ProductCategoryTypeId == null)
            {
                cmd.IsPropertyProductCategoryTypeIdRemoved = true;
            }
            if (state.PrimaryParentCategoryId == null)
            {
                cmd.IsPropertyPrimaryParentCategoryIdRemoved = true;
            }
            if (state.CategoryName == null)
            {
                cmd.IsPropertyCategoryNameRemoved = true;
            }
            if (state.Description == null)
            {
                cmd.IsPropertyDescriptionRemoved = true;
            }
            if (state.CategoryImageUrl == null)
            {
                cmd.IsPropertyCategoryImageUrlRemoved = true;
            }
            if (state.DetailScreen == null)
            {
                cmd.IsPropertyDetailScreenRemoved = true;
            }
            if (state.AttributeSetId == null)
            {
                cmd.IsPropertyAttributeSetIdRemoved = true;
            }
            return(cmd);
        }
예제 #15
0
        public static TDeleteProductCategory ToDeleteProductCategory <TDeleteProductCategory>(this IProductCategoryState state)
            where TDeleteProductCategory : IDeleteProductCategory, new()
        {
            var cmd = new TDeleteProductCategory();

            cmd.ProductCategoryId = state.ProductCategoryId;
            cmd.Version           = ((IProductCategoryStateProperties)state).Version;

            return(cmd);
        }
예제 #16
0
        public static IProductCategoryCommand ToCreateOrMergePatchProductCategory <TCreateProductCategory, TMergePatchProductCategory>(this IProductCategoryState state)
            where TCreateProductCategory : ICreateProductCategory, new()
            where TMergePatchProductCategory : IMergePatchProductCategory, new()
        {
            bool bUnsaved = ((IProductCategoryState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateProductCategory <TCreateProductCategory>());
            }
            else
            {
                return(state.ToMergePatchProductCategory <TMergePatchProductCategory>());
            }
        }