private static void AddProductBrand(IProductCommand command, Product product) { if (command.ProductBrand.Name == null) { return; } var brand = new ProductBrand { Name = command.ProductBrand.Name, CreationDate = DateTime.Now, Creator = command.UserIdentity.Email }; if (command.ProductBrand.IsNew) { product.ProductBrand = brand; //product.ProductCategory = new ProductCategory(); //product.ProductCategory.AddBrand(brand); } else { product.Brand = command.ProductBrand.Name; } }
private void AddProductSize(IProductCommand command, Product product) { if (command.ProductSizes == null) { return; } foreach (var item in command.ProductSizes.Where(c => c.Name != null)) { var size = new ProductSize { Name = item.Name, CreationDate = DateTime.Now, Creator = command.UserIdentity.Email }; if (item.IsNew) { product.AddSize(size); } else { var productSize = _productRepository.GetProductSizeByValue(item.Name); product.ProductSizes.Add(productSize); } } }
private void AddProductAttribute(IProductCommand command, Product product) { if (command.ProductAttributes == null) { return; } foreach (var attribute in command.ProductAttributes) { if (!attribute.IsNew) { continue; } var productAttribute = _productRepository.GetProductAttribute(attribute.AttributeId); product.ProductAttributes.Add(productAttribute); foreach (var option in attribute.AttributeOptionCommands) { var productAttributeOption = _productRepository.GetProductAttributeOption(option.Name); foreach (var item in product.ProductAttributes) { item.AttributeOptions.Add(productAttributeOption); } } } }
private static void SetSelectedValues(IProductCommand command, ProductDto product) { SetSelectdCategory(command, product); SetSelectdBrand(command, product); SetSelectTag(command, product); SetSelectedAttribute(command, product); }
private void FillStores(IProductCommand command) { var query = new StoresQueryRequest(1, 20, CurrentUser.Id); var response = _storeQueryService.GetStores(query); ViewBag.Stores = response.Stores; }
private void AddProductCategory(IProductCommand command, Product product) { if (command.ProductCategory.Name == null) { return; } product.Category = command.ProductCategory.Name; }
public MainViewModel(IProductQuery productQuery, ICustomerQuery customerQuery, IProductCommand productCommand) { _ProductQuery = productQuery; _CustomerQuery = customerQuery; _ProductCommand = productCommand; SetViewModel(); }
public ProductService(IProductQuery productHelper, IDestinationQuery destionationQueryHelper, IProductCommand productCommand ) { this.productHelper = productHelper; this.destionationQueryHelper = destionationQueryHelper; this.productCommand = productCommand; }
private static void AddProduct(IProductCommand command, Product product) { product.Name = command.Name; product.OriginalName = command.OriginalName; product.Description = command.Description; product.Price = command.Price; product.DollarPrice = command.DollarPrice; product.Slug = command.Name.GenerateSlug(); }
public MainViewModel() { _ProductQuery = LogicFactory.ProductQuery; _CustomerQuery = LogicFactory.CustomerQuery; _ProductCommand = LogicFactory.ProductCommand; SetViewModel(); }
/// <summary> /// Find products from given database using given query. /// </summary> /// <param name="query"></param> /// <returns></returns> public IEnumerable <Product> Find(IProductCommand <Product, bool> query) { if (query == null) { throw new ArgumentException("Command can not be null"); } else { return(this.products.Where(query.Command())); } }
private static void SetSelectTag(IProductCommand command, ProductDto product) { if (command.ProductTags == null) { return; } foreach (var tag in product.ProductTags.Where(c => c.Name != null)) { command.ProductTags.First(c => c.Name == tag.Name).IsSelected = true; } }
private static void SetSelectdBrand(IProductCommand command, ProductDto product) { if (command.ProductBrand == null) { return; } if (product.ProductBrand.Name == command.ProductBrand.Name) { command.ProductBrand.IsSelected = true; } }
private static void SetSelectdCategory(IProductCommand command, ProductDto product) { if (command.ProductCategory == null) { return; } if (product.ProductCategory.Name == command.ProductCategory.Name) { command.ProductCategory.IsSelected = true; } }
private void AddProductSpecialState(IProductCommand command, Product product) { if (command.IsInSpecialState) { product.ProductSpecialState = new ProductSpecialState { StartDate = command.ProductSpecialState.StartDate, EndDate = command.ProductSpecialState.EndDate, Description = command.ProductSpecialState.Description }; } }
private void AddProductAttributeOption(IProductCommand command, Product product) { if (command.ProductAttributeOptions == null) { return; } foreach (var item in command.ProductAttributeOptions) { var productAttributeOption = _productRepository.GetProductAttributeOption(item.Name); product.ProductAttributeOptions.Add(productAttributeOption); } }
private void AssignProductToStore(IProductCommand command, Product product) { if (command.StoreCommands == null) { throw new NoStoreHasBeenChoosenForProductException(ProductExceptionMessage.ProductStoreIsNotDeterminded); } foreach (var item in command.StoreCommands) { var store = _storeRepository.GetById(item.StoreId); product.Stores.Add(store); } }
private static void AddProductPicture(IProductCommand command, Product product) { foreach (var productPicture in command.ProductPictures.Select(item => new ProductPicture { Name = item.Name, Address = item.Address, CreationDate = DateTime.Now, LastUpdateDate = DateTime.Now, })) { product.AddPicture(productPicture); } }
protected bool IsRepeatedCommand(IProductCommand command, IEventStoreAggregateId eventStoreAggregateId, IProductState state) { bool repeated = false; if (((IProductStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.GetEvent(typeof(IProductEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
private static void SetSelectedAttribute(IProductCommand command, ProductDto product) { if (command.ProductAttributes == null) { return; } foreach (var attribute in product.ProductCategory.ProductAttributes.Where(c => c.Name != null)) { foreach (var option in attribute.AttributeOptions) { command.ProductAttributes.Select(c => c.AttributeOptionCommands.First(o => o.Name == option.Name).IsSelected == true); } } }
private void AddProductAppurtenance(IProductCommand command, Product product) { AddProduct(command, product); AddProductBrand(command, product); AddProductTag(command, product); AddProductCategory(command, product); AddProductColor(command, product); AddProductPicture(command, product); AddProductSize(command, product); AddProductAttribute(command, product); AddProductAttributeOption(command, product); AssigProductToUser(command, product); AssignProductToStore(command, product); AddProductSpecialState(command, product); }
protected virtual void Update(IProductCommand c, Action <IProductAggregate> action) { var aggregateId = c.AggregateId; var state = StateRepository.Get(aggregateId, false); var aggregate = GetProductAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); var repeated = IsRepeatedCommand(c, eventStoreAggregateId, state); if (repeated) { return; } aggregate.ThrowOnInvalidStateTransition(c); action(aggregate); Persist(eventStoreAggregateId, aggregate, state); }
protected void ThrowOnInconsistentCommands(IProductCommand command, IGoodIdentificationCommand innerCommand) { var properties = command as ICreateOrMergePatchOrDeleteProduct; var innerProperties = innerCommand as ICreateOrMergePatchOrRemoveGoodIdentification; if (properties == null || innerProperties == null) { return; } if (innerProperties.ProductId == default(string)) { innerProperties.ProductId = properties.ProductId; } else { var outerProductIdName = "ProductId"; var outerProductIdValue = properties.ProductId; var innerProductIdName = "ProductId"; var innerProductIdValue = innerProperties.ProductId; ThrowOnInconsistentIds(innerProperties, innerProductIdName, innerProductIdValue, outerProductIdName, outerProductIdValue); } }// END ThrowOnInconsistentCommands /////////////////////
}// END ThrowOnInconsistentCommands ///////////////////// protected virtual IGoodIdentificationEvent Map(IGoodIdentificationCommand c, IProductCommand outerCommand, long version, IProductState outerState) { var create = (c.CommandType == CommandType.Create) ? (c as ICreateGoodIdentification) : null; if (create != null) { return(MapCreate(create, outerCommand, version, outerState)); } var merge = (c.CommandType == CommandType.MergePatch || c.CommandType == null) ? (c as IMergePatchGoodIdentification) : null; if (merge != null) { return(MapMergePatch(merge, outerCommand, version, outerState)); } var remove = (c.CommandType == CommandType.Remove) ? (c as IRemoveGoodIdentification) : null; if (remove != null) { return(MapRemove(remove, outerCommand, version)); } throw new NotSupportedException(); }
public ProductRepository(IUnitOfWork unitOfWork, IProductCommand productCommand, IProductQuery productQuery) : base(unitOfWork) { _productCommand = productCommand; _productQuery = productQuery; }
public ProductController(IProductQuery productQuery, IProductCommand productCommand) { this.productQuery = productQuery; this.productCommand = productCommand; }
private void AssigProductToUser(IProductCommand command, Product product) { var user = _membershipRepository.GetById(command.UserIdentity.Id); product.Users.Add(user); }
private static bool IsCommandCreate(IProductCommand c) { return(c.Version == ProductState.VersionZero); }
private static void Execute(ProductReceiver product, ModifyPriceInvoker modifyPrice, IProductCommand productCommand) { modifyPrice.SetCommand(productCommand); modifyPrice.Invoke(); }
public MainController(int p2p_port = 8081) : base(p2p_port) { _ProductQuery = LogicFactory.ProductQuery; _CustomerQuery = LogicFactory.CustomerQuery; _ProductCommand = LogicFactory.ProductCommand; }