コード例 #1
0
        public virtual ActionResult ArticleTemplateUpdate(ArticleTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var template = _articleTemplateService.GetArticleTemplateById(model.Id);

            if (template == null)
            {
                throw new ArgumentException("No template found with the specified id");
            }
            template = model.ToEntity(template);
            _articleTemplateService.UpdateArticleTemplate(template);

            return(new NullJsonResult());
        }
コード例 #2
0
        public virtual ActionResult ArticleTemplateAdd([Bind(Exclude = "Id")] ArticleTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var template = new ArticleTemplate();

            template = model.ToEntity(template);
            _articleTemplateService.InsertArticleTemplate(template);

            return(new NullJsonResult());
        }
コード例 #3
0
 public static ArticleTemplate ToEntity(this ArticleTemplateModel model, ArticleTemplate destination)
 {
     return(model.MapTo(destination));
 }
コード例 #4
0
 public static ArticleTemplate ToEntity(this ArticleTemplateModel model)
 {
     return(model.MapTo <ArticleTemplateModel, ArticleTemplate>());
 }