public IActionResult ManufacturerTemplateAdd(ManufacturerTemplateModel model)
 {
     if (!ModelState.IsValid)
     {
         return(Json(new DataSourceResult {
             Errors = ModelState.SerializeErrors()
         }));
     }
     if (ModelState.IsValid)
     {
         var template = new ManufacturerTemplate();
         template = model.ToEntity(template);
         _manufacturerTemplateService.InsertManufacturerTemplate(template);
         return(new NullJsonResult());
     }
     return(ErrorForKendoGridJson(ModelState));
 }
Exemplo n.º 2
0
        public virtual IActionResult ManufacturerTemplateAdd(ManufacturerTemplateModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

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

            var template = new ManufacturerTemplate();

            template = model.ToEntity(template);
            _manufacturerTemplateService.InsertManufacturerTemplate(template);

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

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

            var template = new ManufacturerTemplate();

            template = model.ToEntity(template);
            _manufacturerTemplateService.InsertManufacturerTemplate(template);

            return(new NullJsonResult());
        }
Exemplo n.º 4
0
        public ActionResult ManufacturerTemplateAdd([Bind(Exclude = "Id")] ManufacturerTemplateModel 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 ManufacturerTemplate();

            template = model.ToEntity(template);
            _manufacturerTemplateService.InsertManufacturerTemplate(template);

            return(ManufacturerTemplates(command));
        }