// Bubble up visible products to parent categories public async Task Handle(CategoryActivated message) { var cat = _categoryRepository.GetById(message.Id); cat.IsActivated = true; _categoryRepository.Update(cat); Guid?parentId = cat.ParentId; while (parentId != null) { var parentCat = _categoryRepository.GetById(parentId.Value); parentCat.TotalVisibleProducts += cat.TotalVisibleProducts; _categoryRepository.Update(parentCat); parentId = parentCat.ParentId; } }
private void Apply(CategoryActivated e) { Activated = true; }