public virtual ActionResult ProductTemplateUpdate(ProductTemplateModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(Json(new DataSourceResult { Errors = ModelState.SerializeErrors() })); } var template = _productTemplateService.GetProductTemplateById(model.Id); if (template == null) { throw new ArgumentException("No template found with the specified id"); } template = model.ToEntity(template); _productTemplateService.UpdateProductTemplate(template); return(new NullJsonResult()); }
public ActionResult ProductTemplateUpdate(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 = _productTemplateService.GetProductTemplateById(model.Id); if (template == null) { throw new ArgumentException("No template found with the specified id"); } template = model.ToEntity(template); _productTemplateService.UpdateProductTemplate(template); return(ProductTemplates(command)); }
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)); }
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 })); }
public virtual IActionResult ProductTemplateUpdate(ProductTemplateModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(ErrorJson(ModelState.SerializeErrors())); } //try to get a product template with the specified id var template = _productTemplateService.GetProductTemplateById(model.Id) ?? throw new ArgumentException("No template found with the specified id"); template = model.ToEntity(template); _productTemplateService.UpdateProductTemplate(template); return(new NullJsonResult()); }
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()); }
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)); }
public IActionResult ProductTemplateUpdate(ProductTemplateModel model) { if (!ModelState.IsValid) { return(Json(new DataSourceResult { Errors = ModelState.SerializeErrors() })); } var template = _productTemplateService.GetProductTemplateById(model.Id); if (template == null) { throw new ArgumentException("No template found with the specified id"); } if (ModelState.IsValid) { template = model.ToEntity(template); _productTemplateService.UpdateProductTemplate(template); return(new NullJsonResult()); } return(ErrorForKendoGridJson(ModelState)); }