Advertisement
Guest User

Untitled

a guest
Jul 28th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1.  
  2. BootstrapContainer();
  3.  
  4. // base binders
  5. System.Web.Mvc.ModelBinders.Binders.Add(typeof(DateTime), new EOIS.ModelBinders.DateTimeCultureSpecificBinder());
  6. System.Web.Mvc.ModelBinders.Binders.Add(typeof(DateTime?), new EOIS.ModelBinders.DateTimeCultureSpecificBinder());
  7.  
  8. // demand specific binders
  9. var dSat = container.Resolve<DemandsSanitization>();
  10. System.Web.Mvc.ModelBinders.Binders.Add(typeof(TelcoDemandViewModel), new EOIS.ModelBinders.TelcoDemandViewModelBinder(dSat));
  11. System.Web.Mvc.ModelBinders.Binders.Add(typeof(ElectricityDemandViewModel), new EOIS.ModelBinders.ElectricityDemandViewModelBinder(dSat));
  12. System.Web.Mvc.ModelBinders.Binders.Add(typeof(EnergyDemandViewModel), new EOIS.ModelBinders.EnergyDemandViewModelBinder(dSat));
  13. System.Web.Mvc.ModelBinders.Binders.Add(typeof(LoanDemandVM), new EOIS.ModelBinders.LoanDemandViewModelBinder(dSat)); var dSat = container.Resolve<DemandsSanitization>();
  14. System.Web.Mvc.ModelBinders.Binders.Add(typeof(TelcoDemandViewModel), new EOIS.ModelBinders.TelcoDemandViewModelBinder(dSat));
  15.  
  16.  
  17.  
  18.  
  19. public class TelcoDemandViewModelBinder : BaseDemandViewModelBinder
  20. {
  21. public TelcoDemandViewModelBinder(DemandsSanitization dSanitization) : base(dSanitization) { }
  22.  
  23. public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
  24. {
  25. var demandVm = (TelcoDemandViewModel) base.BindModel(controllerContext, bindingContext);
  26.  
  27.  
  28. if (demandVm.SimCardsValid != null)
  29. {
  30. foreach (var sim in demandVm.SimCardsValid)
  31. {
  32. sim.PhoneNumber = DemandsSanitization.SanitizePhoneNumber(sim.PhoneNumber);
  33. }
  34. }
  35.  
  36. return demandVm;
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement