Exemple #1
0
        public virtual IActionResult CategoryTemplateAdd(CategoryTemplateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }

            CategoryTemplate template = new CategoryTemplate();

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

            return(new NullJsonResult());
        }
Exemple #2
0
        public async Task <IActionResult> CategoryTemplateAdd(CategoryTemplateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new DataSourceResult {
                    Errors = ModelState.SerializeErrors()
                }));
            }
            if (ModelState.IsValid)
            {
                var template = new CategoryTemplate();
                template = model.ToEntity(template);
                await _categoryTemplateService.InsertCategoryTemplate(template);

                return(new NullJsonResult());
            }
            return(ErrorForKendoGridJson(ModelState));
        }
Exemple #3
0
        public virtual IActionResult CategoryTemplateAdd(CategoryTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(ErrorJson(ModelState.SerializeErrors()));
            }

            var template = new CategoryTemplate();

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

            return(Json(new { Result = true }));
        }
        public virtual ActionResult CategoryTemplateAdd([Bind(Exclude = "Id")] CategoryTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

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

            var template = new CategoryTemplate();

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

            return(new NullJsonResult());
        }
Exemple #5
0
        public ActionResult CategoryTemplateAdd([Bind(Exclude = "Id")] 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 = new CategoryTemplate();

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

            return(CategoryTemplates(command));
        }