Browse Source
Merge pull request #9057 from abpframework/maliming/AbpDateTimeModelBinder-patch
Handle the case where datetime is null.
pull/9072/head
liangshiwei
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
2 additions and
3 deletions
-
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinder.cs
|
|
|
@ -20,10 +20,9 @@ namespace Volo.Abp.AspNetCore.Mvc.ModelBinding |
|
|
|
public async Task BindModelAsync(ModelBindingContext bindingContext) |
|
|
|
{ |
|
|
|
await _dateTimeModelBinder.BindModelAsync(bindingContext); |
|
|
|
if (bindingContext.Result.IsModelSet) |
|
|
|
if (bindingContext.Result.IsModelSet && bindingContext.Result.Model is DateTime dateTime) |
|
|
|
{ |
|
|
|
// ReSharper disable once PossibleNullReferenceException
|
|
|
|
bindingContext.Result = ModelBindingResult.Success(_clock.Normalize((DateTime) bindingContext.Result.Model)); |
|
|
|
bindingContext.Result = ModelBindingResult.Success(_clock.Normalize(dateTime)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|