예제 #1
0
        public async ValueTask <IActionResult> CategoryUp(string name)
        {
            await categoriesAdminManager.CategoryUp(name);

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

            return(Ok());
        }
예제 #2
0
        public async void ShouldMoveCategoryUp()
        {
            var category1 = DefaultCategory;
            var category2 = DefaultCategory2;

            using (dbConnection.BeginTransaction())
            {
                await categoryAdminManager.CreateCategoryAsync(category1);

                await categoryAdminManager.CreateCategoryAsync(category2);

                int sortNumber1 = dbConnection.Categories.First(x => x.Name == category1.Name).SortNumber;
                int sortNumber2 = dbConnection.Categories.First(x => x.Name == category2.Name).SortNumber;

                await categoryAdminManager.CategoryUp(category2.Name);

                int sortNumber1Next = dbConnection.Categories.First(x => x.Name == category1.Name).SortNumber;
                int sortNumber2Next = dbConnection.Categories.First(x => x.Name == category2.Name).SortNumber;

                Assert.Equal(sortNumber1, sortNumber2Next);
                Assert.Equal(sortNumber2, sortNumber1Next);
            }
        }
        public async Task <IActionResult> CategoryUp(string name)
        {
            var rez = await categoriesAdminManager.CategoryUp(name);

            if (rez.Failed)
            {
                return(BadRequest());
            }

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

            return(Ok());
        }