public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }

            if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }

            var retVal   = new RecommendationEvalContext();
            var provider = bindingContext.ValueProvider.GetValue("provider");

            if (provider != null && provider.RawValue != null && provider.RawValue.ToString().EqualsInvariant("Cognitive"))
            {
                retVal = new CognitiveRecommendationEvalContext();
            }
            controllerContext.HttpContext.Request.InputStream.Seek(0, SeekOrigin.Begin);
            var reader   = new StreamReader(controllerContext.HttpContext.Request.InputStream);
            var bodyText = reader.ReadToEnd();
            var settings = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            };

            JsonConvert.PopulateObject(bodyText, retVal, settings);
            return(retVal);
        }
        public virtual dto.RecommendationEvalContext ToContextDto(CognitiveRecommendationEvalContext context)
        {
            var retVal = new dto.RecommendationEvalContext
            {
                BuildId    = context.BuildId,
                ModelId    = context.ModelId,
                ProductIds = context.ProductIds.Where(x => !string.IsNullOrEmpty(x)).ToList(),
                StoreId    = context.StoreId,
                Take       = context.Take,
                Type       = context.Type,
                UserId     = context.UserId
            };

            return(retVal);
        }
 public static dto.RecommendationEvalContext ToContextDto(this CognitiveRecommendationEvalContext context)
 {
     return(RecommendationConverterInstance.ToContextDto(context));
 }