CustomerModelBinder.cs 684 B

123456789101112131415161718192021222324
  1. using Microsoft.AspNetCore.Mvc.ModelBinding;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. namespace GreenTree.Strohrmann.ERP.Web.Models
  7. {
  8. public class CustomerModelBinder : IModelBinder
  9. {
  10. public Task BindModelAsync(ModelBindingContext bindingContext)
  11. {
  12. if (bindingContext == null)
  13. {
  14. throw new ArgumentNullException(nameof(bindingContext));
  15. }
  16. // Try to fetch the value of the argument by name
  17. var valueProviderResult = bindingContext.ValueProvider.GetValue("Lastname");
  18. return Task.CompletedTask;
  19. }
  20. }
  21. }