/// <summary> /// return an index page according to the inputs /// </summary> /// <returns></returns> public ActionResult IndexWithInputs() { dynamic obj = GetJsonObject(Request.InputStream); // retrieve the quant QuantizationFactorsArray quantArray = JsonHelper.RetrieveQuantsArray(obj.Params.QuantizationFactorsArray); EntropyAlgorithm algorithm = JsonHelper.CastTo <EntropyAlgorithm>(obj.Params.EntropyAlgorithm); _viewModel = new RFXDecodeViewModel(); // Updates parameters ((RFXDecodeViewModel)_viewModel).ProvideParam(quantArray, algorithm); Triplet <string> triplet = JsonHelper.RetrieveTriplet(obj.Inputs); ((RFXDecodeViewModel)_viewModel).ProvidePanelInputs(triplet.ToArray()); var envValues = new Dictionary <string, object>() { { ModelKey, _viewModel }, { isModelValid, true } }; SaveToSession(envValues); return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public async Task <IActionResult> IndexWithInputs() { try { using (var bodyStream = new StreamReader(Request.Body)) { var bodyText = await bodyStream.ReadToEndAsync(); dynamic obj = JsonConvert.DeserializeObject(bodyText); // retrieve the quant QuantizationFactorsArray quantArray = JsonHelper.RetrieveQuantsArray(obj.Params.QuantizationFactorsArray); EntropyAlgorithm algorithm = JsonHelper.CastTo <EntropyAlgorithm>(obj.Params.EntropyAlgorithm); _viewModel = new RFXDecodeViewModel(); // Updates parameters ((RFXDecodeViewModel)_viewModel).ProvideParam(quantArray, algorithm); Triplet <string> triplet = JsonHelper.RetrieveTriplet(obj.Inputs); ((RFXDecodeViewModel)_viewModel).ProvidePanelInputs(triplet.ToArray()); var envValues = new Dictionary <string, object>() { { ModelKey, _viewModel }, { isModelValid, true } }; SaveToSession(envValues); } return(Json(ReturnResult <string> .Success("Success"))); } catch (Exception ex) { return(Json(ReturnResult <string> .Fail(ex.Message))); } }