public async Task <IActionResult> CreateCategory([FromBody] CategoryRequestModel categoryData)
        {
            if (!ModelState.IsValid)
            {
                return(ValidationProblem());
            }

            var sectionType = categoriesCache.AllSectionTypes.ContainsKey(categoryData.SectionTypeName)
                ? categoriesCache.AllSectionTypes[categoryData.SectionTypeName]
                : null;

            var category = categoryData.ToCategory();

            category.SectionTypeId = sectionType?.Id;

            if (!categoryData.AppendUrlToken.HasValue)
            {
                if (sectionType != null)
                {
                    category.AppendUrlToken = true;
                }
            }
            else
            {
                category.AppendUrlToken = categoryData.AppendUrlToken.Value;
            }

            await categoriesAdminManager.CreateCategoryAsync(category);

            categoriesCache.Reset();
            contentCache.Reset();

            return(Ok());
        }
Exemplo n.º 2
0
        public async ValueTask <IActionResult> CreateCategory([FromBody] CategoryRequestModel categoryData)
        {
            if (!ModelState.IsValid)
            {
                return(ValidationProblem());
            }

            var category = categoryData.ToCategory();

            await categoriesAdminManager.CreateCategoryAsync(category);

            categoriesCache.Reset();
            contentCache.Reset();

            return(Ok());
        }