Beispiel #1
0
        public string Get(StringArrayModel viewModel)
        {
            if (viewModel == null)
            {
                return("Woops. We received null!");
            }

            Debug.WriteLine(viewModel.ValuesList.Length);

            return($"data model: {JsonConvert.SerializeObject(viewModel.ValuesList)}");
        }
        public Task BindModelAsync(ModelBindingContext bindingContext)
        {
            string day   = bindingContext.ActionContext.HttpContext.Request.Query["d"];
            string month = bindingContext.ActionContext.HttpContext.Request.Query["m"];
            string year  = bindingContext.ActionContext.HttpContext.Request.Query["y"];

            //if (!(bindingContext.ActionContext.HttpContext.Request.Query["day"], out day) ||
            //    !int.TryParse(bindingContext.ActionContext.HttpContext.Request.Query["month"], out month) ||
            //    !int.TryParse(bindingContext.ActionContext.HttpContext.Request.Query["year"], out year))
            //{
            //    return Task.CompletedTask;
            //}

            var result = new StringArrayModel
            {
                ValuesList = new[] { day ?? string.Empty, month ?? string.Empty, year ?? string.Empty }
            };

            bindingContext.Result = ModelBindingResult.Success(result);
            return(Task.CompletedTask);
        }