示例#1
0
        public virtual ActionResult CategoryTemplateUpdate(CategoryTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

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

            var template = _categoryTemplateService.GetCategoryTemplateById(model.Id);

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

            return(new NullJsonResult());
        }
示例#2
0
        public ActionResult CategoryTemplateUpdate(CategoryTemplateModel model, GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                //display the first model error
                var modelStateErrors = this.ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage);
                return(Content(modelStateErrors.FirstOrDefault()));
            }

            var template = _categoryTemplateService.GetCategoryTemplateById(model.Id);

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

            return(CategoryTemplates(command));
        }
示例#3
0
        public virtual IActionResult CategoryTemplateUpdate(CategoryTemplateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            //try to get a category template with the specified id
            CategoryTemplate template = _categoryTemplateService.GetCategoryTemplateById(model.Id)
                                        ?? throw new ArgumentException("No template found with the specified id");

            template = model.ToEntity(template);
            _categoryTemplateService.UpdateCategoryTemplate(template);

            return(new NullJsonResult());
        }
示例#4
0
        public async Task <IActionResult> CategoryTemplateUpdate(CategoryTemplateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            var template = await _categoryTemplateService.GetCategoryTemplateById(model.Id);

            if (template == null)
            {
                throw new ArgumentException("No template found with the specified id");
            }
            if (ModelState.IsValid)
            {
                template = model.ToEntity(template);
                await _categoryTemplateService.UpdateCategoryTemplate(template);

                return(new NullJsonResult());
            }
            return(ErrorForKendoGridJson(ModelState));
        }