예제 #1
0
 public void EditCategory(Category category, string newName)
 {
     category.Name = newName;
     CategoryAdded?.Invoke(category);
     _logger.Log($"Внесены изменения в категорию {category.Name}");
     SaveData();
 }
예제 #2
0
        public void AddCategory(Category category, Shop shop)
        {
            if (shop.Categories.Exists(c => c.Name == category.Name))
            {
                throw new Exception("Такая категория уже существует!");
            }

            shop.Categories.Add(category);
            CategoryAdded?.Invoke(category);
            _logger.Log($"Добавлена новая категория {category.Name}");
            SaveData();
        }
예제 #3
0
        protected async Task AddCategoryToPost()
        {
            try
            {
                var category = CategoriesList?.FirstOrDefault(c => c.CategoryId == SelectedCategoryId);
                if (category is null)
                {
                    throw new UserException("Please Select a category from the list.");
                }

                await CategoryAdded.InvokeAsync(category);
            }
            catch (Exception e)
            {
                await OnExecutableError.InvokeAsync(e);
            }
        }
예제 #4
0
 public void Apply(CategoryAdded e)
 {
     Categories[e.CategoryId] = new Category(e.CategoryId, e.Group, e.Hierarchy);
 }