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); }
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(); }
public ProductCategoryAggregate(IProductCategoryState state) { _state = state; }
public override IProductCategoryAggregate GetProductCategoryAggregate(IProductCategoryState state) { return(new ProductCategoryAggregate(state)); }
public ProductCategoryStateDtoWrapper(IProductCategoryState state) { this._state = state; }
public ProductCategoryStateDtoWrapper() { this._state = new ProductCategoryState(); }
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); }
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)); } }
public abstract IProductCategoryAggregate GetProductCategoryAggregate(IProductCategoryState state);
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); }
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); }
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); }
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>()); } }