public async Task <IActionResult> CreateForLoop(int id, [Bind("ID, MethodName, ArrayName, CodeName")] ForLoop forLoop)
        {
            ForLoopForm forLoopForm = new ForLoopForm(forLoop.MethodName, forLoop.ArrayName);

            string  inputs  = JsonConvert.SerializeObject(forLoopForm);
            ApiData apiData = new ApiData(forLoop.ID, forLoop.CodeName, inputs);

            if (ModelState.IsValid)
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("https://codetalkapi.azurewebsites.net/api/");
                    HttpResponseMessage response = await client.PostAsync(client.BaseAddress, new StringContent(inputs, Encoding.UTF8, "application/json"));

                    //HttpResponseMessage response = await client.GetAsync($"default/{id}");


                    var stringResult = await response.Content.ReadAsStringAsync();

                    Results rawSentence = JsonConvert.DeserializeObject <Results>(stringResult);

                    return(View("Index", new Results
                    {
                        ID = rawSentence.ID,
                        baseString = rawSentence.baseString,
                        Option = rawSentence.Option
                    }));
                }
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        // 插入指令:次数循环
        private void button8_Click(object sender, EventArgs e)
        {
            // 检查这个节点可否插入
            if (this.isAbleInsert() == false)
            {
                return;
            }
            this.moveCursorToPoint(this, new Point(this.Size.Width / 2, this.Size.Height / 2), Cursor.Position, 0, 0);
            ForLoopForm flf = new ForLoopForm();

            flf.ShowDialog(this);
        }