예제 #1
0
        protected virtual IActionResult Get(MaterialView materialView)
        {
            if (materialView == null)
            {
                return(BadRequest());
            }

            var category = categoriesCache.GetCategory(materialView.CategoryName);

            if (!materialsAuthorization.CanGet(User.Roles, category))
            {
                return(Unauthorized());
            }

            if (materialView.IsHidden && !materialsAuthorization.CanHide(User.Roles, category))
            {
                return(Unauthorized());
            }

            if (materialView.DeletedDate != null && !materialsAuthorization.CanRestoreAsync(User, category.Id))
            {
                return(Unauthorized());
            }

            materialView.VisitsCount += materialsVisitsCounterCache.CountMaterial(UserOrIpKey, materialView.Id);

            return(Json(materialView));
        }
예제 #2
0
        protected virtual IActionResult Get(MaterialView materialView)
        {
            if (materialView == null)
            {
                return(BadRequest());
            }

            var category = categoriesCache.GetCategory(materialView.CategoryName);

            if (!materialsAuthorization.CanGet(User.Roles, category))
            {
                return(Unauthorized());
            }

            if (materialView.IsHidden && !materialsAuthorization.CanHide(User.Roles, category))
            {
                return(Unauthorized());
            }

            if (materialView.IsDeleted && !materialsAuthorization.CanRestoreAsync(User, category.Id))
            {
                return(Unauthorized());
            }

            return(Json(materialView));
        }