Beispiel #1
0
        public void RemoveCategory(Guid categoryId)
        {
            var removedCategory =
                ProductCategories.SingleOrDefault(g => g.CategoryId == categoryId && g.ProductId == Id);

            if (removedCategory == null)
            {
                throw new NotFoundException(nameof(categoryId), categoryId);
            }
            ProductCategories.Remove(removedCategory);
        }
        private void OnAfterCategorySaved(Category model)
        {
            var category = ProductCategories.SingleOrDefault(x => x.Id == model.Id);

            if (category == null)
            {
                ProductCategories.Add(new CategoryWrapper(model));
            }
            else
            {
                category.Update(model);
            }
        }