forked from ddrilling/AsbCloudServer
правки по валидации
This commit is contained in:
parent
672f78fca9
commit
4bd0a835fc
@ -237,8 +237,8 @@ namespace AsbCloudWebApi.Controllers
|
||||
wellOperation.IdUser = User.GetUserId();
|
||||
wellOperation.IdType = idType;
|
||||
|
||||
var validationResult = awaitoperationRepository.ValidateWithDbAsync(new[] { wellOperation }, cancellationToken);
|
||||
if(validationResult.Any())
|
||||
var validationResult = await operationRepository.ValidateWithDbAsync(new[] { wellOperation }, cancellationToken);
|
||||
if (validationResult.Any())
|
||||
return this.ValidationBadRequest(validationResult);
|
||||
|
||||
var result = await operationRepository.InsertRangeAsync(new[] { wellOperation }, cancellationToken);
|
||||
@ -292,7 +292,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
}
|
||||
|
||||
|
||||
var validationResult = Validate(wellOperations, deleteBeforeInsert, cancellationToken);
|
||||
var validationResult = await Validate(wellOperations, deleteBeforeInsert, cancellationToken);
|
||||
if (validationResult.Any())
|
||||
return this.ValidationBadRequest(validationResult);
|
||||
|
||||
@ -309,7 +309,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <param name="deleteBeforeInsert"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
private IEnumerable<ValidationResult> Validate(IEnumerable<WellOperationDto> wellOperations, bool deleteBeforeInsert, CancellationToken cancellationToken)
|
||||
private async Task<IEnumerable<ValidationResult>> Validate(IEnumerable<WellOperationDto> wellOperations, bool deleteBeforeInsert, CancellationToken cancellationToken)
|
||||
{
|
||||
if (deleteBeforeInsert)
|
||||
return operationRepository.Validate(wellOperations);
|
||||
|
@ -65,8 +65,7 @@ namespace Microsoft.AspNetCore.Mvc
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="controller"></param>
|
||||
/// <param name="paramName"></param>
|
||||
/// <param name="error"></param>
|
||||
/// <param name="validationResults"></param>
|
||||
/// <returns></returns>
|
||||
public static BadRequestObjectResult ValidationBadRequest(this ControllerBase controller, IEnumerable<ValidationResult> validationResults)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user