Пример #1
0
        public virtual ActionResult SaveFile(long articleId, ArticleFileViewModel model)
        {
            if (ModelState.IsValid)
            {
                var article = articleService.Find(articleId);
                if (article == null || !permissionService.IsAllowed((Int32)ArticleOperations.Manage, this.CorePrincipal(), typeof(Article), article.Id, IsArticleOwner(article), PermissionOperationLevel.Object))
                {
                    throw new HttpException((int)HttpStatusCode.NotFound, HttpContext.Translate("Messages.NotFound", ResourceHelper.GetControllerScope(this)));
                }

                if (articleFileService.Save(model.MapTo(new ArticleFile())))
                {
                    Success(HttpContext.Translate("Messages.Success", String.Empty));
                    return(RedirectToAction(WebContentMVC.Article.ShowFiles(articleId)));
                }
            }

            model.AllowManage = true;
            Error(HttpContext.Translate("Messages.ValidationError", String.Empty));
            return(View("ArticleFileDetails", model));
        }