Exemplo n.º 1
0
        public ActionResult PostTemplateUpdate(PostTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

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

            var template = _postTemplateService.GetPostTemplateById(model.Id);

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

            return(new NullJsonResult());
        }
Exemplo n.º 2
0
        public ActionResult PostTemplateAdd([Bind(Exclude = "Id")] PostTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

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

            var template = new PostTemplate();

            template = model.ToEntity(template);
            _postTemplateService.InsertPostTemplate(template);

            return(new NullJsonResult());
        }