Esempio n. 1
0
        public ActionResult EditBlogItem(int id)
        {
            ICollection <Category> cats = _newsCategoryService.GetAllCategories();

            ViewBag.Categories = cats;
            int userId = _principalResolver.GetUserId();
            var item   = _newsItemService.GetNewsItem(id);

            if (!item.BlogId.HasValue)
            {
                throw new UnauthorizedAccessException();
            }

            var blog = _blogService.GetBlog(item.BlogId.Value);

            if (blog.OwnerId != userId)
            {
                throw new UnauthorizedAccessException();
            }

            return(View("BlogItemEditor", item));
        }