Exemple #1
0
        public async Task AddEditCategory(CategoryInput input)
        {
            var id = await _categoryManager.AddEditCategory(input.Name.Sluggify(), input.Name);

            var categoryCreated = _categoryRepository.FirstOrDefault(id);

            foreach (var inputLanguageInput in input.LanguageInputs)
            {
                if (string.IsNullOrEmpty(inputLanguageInput.Text))
                {
                    continue;
                }
                var foundWithSameLanguage =
                    _categoryContentRepository.FirstOrDefault(
                        a => a.CategoryId == id && a.Lang == inputLanguageInput.Lang);
                if (foundWithSameLanguage == null)
                {
                    await
                    _categoryManager.AddEditCategoryContent(
                        CategoryContent.CreateCategoryContent(inputLanguageInput.Lang, inputLanguageInput.Text,
                                                              categoryCreated));
                }
                else
                {
                    foundWithSameLanguage.DisplayText = inputLanguageInput.Text;
                    await _categoryManager.AddEditCategoryContent(foundWithSameLanguage);
                }
            }
        }