Former-commit-id: d9e32b525b38e905b0b2e2d56f13088ac0fdcd15
Former-commit-id: a00d3db9d6fe34b6967ca6bc87a68b580a61b86e
TSXN
wanggang 5 years ago
parent 1ceaa61bc7
commit 01c6c6ab99

@ -222,7 +222,7 @@ namespace Infrastructure.Extensions
} }
else if (attribute is StringLengthAttribute stringLengthAttribute) else if (attribute is StringLengthAttribute stringLengthAttribute)
{//minLength,maxLength {//minLength,maxLength
json.rangelength = new json.rangeLength = new
{ {
min = stringLengthAttribute.MinimumLength, min = stringLengthAttribute.MinimumLength,
max = stringLengthAttribute.MaximumLength, max = stringLengthAttribute.MaximumLength,

@ -79,6 +79,12 @@ namespace Infrastructure.Web.Mvc
return Result(model); return Result(model);
} }
[HttpPost]
public virtual IActionResult AddApi([FromBody] TEditModel model)
{
return this.Add(model);
}
[HttpPost] [HttpPost]
public virtual IActionResult Add(TEditModel model) public virtual IActionResult Add(TEditModel model)
{ {
@ -91,7 +97,7 @@ namespace Infrastructure.Web.Mvc
this.ToEntity(model, entity); this.ToEntity(model, entity);
this.Repo.Add(entity); this.Repo.Add(entity);
this.Repo.SaveChanges(); this.Repo.SaveChanges();
return RedirectTo(); return this.Success();
} }
catch (DbUpdateException ex) catch (DbUpdateException ex)
{ {
@ -128,7 +134,7 @@ namespace Infrastructure.Web.Mvc
entity.From(model, skipReadonly: true); entity.From(model, skipReadonly: true);
this.ToEntity(model, entity); this.ToEntity(model, entity);
this.Repo.SaveChanges(); this.Repo.SaveChanges();
return RedirectTo(); return this.Success();
} }
catch (DbUpdateException ex) catch (DbUpdateException ex)
{ {

@ -128,7 +128,7 @@
this.validInternal(property.maxLength, name, o => Promise.resolve(value.length <= property.maxLength.max)) this.validInternal(property.maxLength, name, o => Promise.resolve(value.length <= property.maxLength.max))
); );
list.push( 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( list.push(
this.validInternal(property.range, name, o => Promise.resolve(parseFloat(value) >= property.range.min && parseFloat(value) <= property.range.max)) 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) { validInternal: function (validator, name, valid, message) {
if (validator) { if (validator) {
console.log('match:' + validator.message);
var vm = this; var vm = this;
message = message || validator.message; message = message || validator.message;
return valid().then(function (value) { return valid().then(function (value) {

Loading…
Cancel
Save