public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext) { if (bindingContext.ModelType != typeof(CreateGenericProductCommand)) { return(false); } //TODO: fill the object from the request json body var dto = new CreateGenericProductCommand(); dto.Title = "X"; dto.ConstraintValues = new List <ConstraintValueDto>() { new NumericConstraintValueDto() { ConstraintId = 1, Max = 10, Min = 0 }, new StringConstraintValueDto() { ConstraintId = 2, MaxLength = 255 } }; //var provider = new CompositeModelBinderProvider(actionContext.ControllerContext.Configuration.Services.GetModelBinderProviders()); //var binder = provider.GetBinder(actionContext.ControllerContext.Configuration, typeof(CreateGenericProductCommand)); bindingContext.Model = dto; return(true); }
public void Post([ModelBinder(typeof(ProductModelBinder))] CreateGenericProductCommand command) { _commandBus.Dispatch(command); }
public void Post(CreateGenericProductCommand command) { //TODO: use a model binder here and remove this hard-coded command initialization! _bus.Dispatch(command); }