Esempio n. 1
0
        public async Task <IActionResult> Down(int id, int countMove = 1)
        {
            Material material = await materialManager.GetAsync(id);

            if (material != null)
            {
                if (countMove <= 0 || material.SortNumber - countMove < 1)
                {
                    return(BadRequest("Incorrect count move"));
                }
                if (await materialsAuthorization.CanUpdateAsync(User, material))
                {
                    try
                    {
                        await materialManager.DownAsync(id);

                        return(Ok());
                    }
                    catch
                    {
                    }
                }
                else
                {
                    return(Forbid());
                }
            }
            return(BadRequest("Invalid article ID"));
        }
Esempio n. 2
0
        public virtual async Task<IActionResult> Down(int id)
        {
            int? categoryId = await materialsManager.GetCategoryIdAsync(id);
            if (!categoryId.HasValue)
                return BadRequest();

            if (materialsAuthorization.CanChangeOrder(User.Roles, categoryId.Value))
                return Unauthorized();

            await materialsManager.DownAsync(id);

            contentCache.InvalidateCache(categoryId.Value);

            return Ok();
        }