public IActionResult ProductTemplateAdd(ProductTemplateModel model)
 {
     if (!ModelState.IsValid)
     {
         return(Json(new DataSourceResult {
             Errors = ModelState.SerializeErrors()
         }));
     }
     if (ModelState.IsValid)
     {
         var template = new ProductTemplate();
         template = model.ToEntity(template);
         _productTemplateService.InsertProductTemplate(template);
         return(new NullJsonResult());
     }
     return(ErrorForKendoGridJson(ModelState));
 }
Ejemplo n.º 2
0
        public virtual IActionResult ProductTemplateAdd(ProductTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

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

            var template = new ProductTemplate();

            template = model.ToEntity(template);
            _productTemplateService.InsertProductTemplate(template);

            return(Json(new { Result = true }));
        }
Ejemplo n.º 3
0
        public virtual ActionResult ProductTemplateAdd([Bind(Exclude = "Id")] ProductTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

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

            var template = new ProductTemplate();

            template = model.ToEntity(template);
            _productTemplateService.InsertProductTemplate(template);

            return(new NullJsonResult());
        }
Ejemplo n.º 4
0
        public ActionResult ProductTemplateAdd([Bind(Exclude = "Id")] ProductTemplateModel 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 ProductTemplate();

            template = model.ToEntity(template);
            _productTemplateService.InsertProductTemplate(template);

            return(ProductTemplates(command));
        }