diff --git a/projects/Infrastructure/Extensions/ControllerExtensions.cs b/projects/Infrastructure/Extensions/ControllerExtensions.cs index 4cecbd72..53e423b0 100644 --- a/projects/Infrastructure/Extensions/ControllerExtensions.cs +++ b/projects/Infrastructure/Extensions/ControllerExtensions.cs @@ -222,7 +222,7 @@ namespace Infrastructure.Extensions } else if (attribute is StringLengthAttribute stringLengthAttribute) {//minLength,maxLength - json.rangelength = new + json.rangeLength = new { min = stringLengthAttribute.MinimumLength, max = stringLengthAttribute.MaximumLength, diff --git a/projects/Infrastructure/Web/Mvc/CrudController.cs b/projects/Infrastructure/Web/Mvc/CrudController.cs index 61eb2f0e..a5c24738 100644 --- a/projects/Infrastructure/Web/Mvc/CrudController.cs +++ b/projects/Infrastructure/Web/Mvc/CrudController.cs @@ -79,6 +79,12 @@ namespace Infrastructure.Web.Mvc return Result(model); } + [HttpPost] + public virtual IActionResult AddApi([FromBody] TEditModel model) + { + return this.Add(model); + } + [HttpPost] public virtual IActionResult Add(TEditModel model) { @@ -91,7 +97,7 @@ namespace Infrastructure.Web.Mvc this.ToEntity(model, entity); this.Repo.Add(entity); this.Repo.SaveChanges(); - return RedirectTo(); + return this.Success(); } catch (DbUpdateException ex) { @@ -128,7 +134,7 @@ namespace Infrastructure.Web.Mvc entity.From(model, skipReadonly: true); this.ToEntity(model, entity); this.Repo.SaveChanges(); - return RedirectTo(); + return this.Success(); } catch (DbUpdateException ex) { diff --git a/projects/WebMVC/wwwroot/router/shared/edit.html b/projects/WebMVC/wwwroot/router/shared/edit.html index 846392b2..c87e13f9 100644 --- a/projects/WebMVC/wwwroot/router/shared/edit.html +++ b/projects/WebMVC/wwwroot/router/shared/edit.html @@ -128,7 +128,7 @@ this.validInternal(property.maxLength, name, o => Promise.resolve(value.length <= property.maxLength.max)) ); list.push( - this.validInternal(property.rangelength, name, o => Promise.resolve(value.length >= property.length.min && value.length <= property.length.max)) + this.validInternal(property.rangeLength, name, o => Promise.resolve(value.length >= property.rangeLength.min && value.length <= property.rangeLength.max)) ); list.push( this.validInternal(property.range, name, o => Promise.resolve(parseFloat(value) >= property.range.min && parseFloat(value) <= property.range.max)) @@ -165,6 +165,7 @@ }, validInternal: function (validator, name, valid, message) { if (validator) { + console.log('match:' + validator.message); var vm = this; message = message || validator.message; return valid().then(function (value) {