コード例 #1
0
        public void CleanUp()
        {
            DataModel = new AnswerDataModel();
            DataModel.ItemRight.ItemId = 22051;
            DataModel.ItemRight.Count  = 1;
            DataModel.ItemWrong.ItemId = 22052;
            DataModel.ItemWrong.Count  = 1;
            MaxCount = int.Parse(Table.GetClientConfig(581).Value);
            var _tbGift1 = Table.GetGift(2000);
            var _tbGift2 = Table.GetGift(2001);

            m_iGiftCount1 = _tbGift1.Param[0];
            m_iGiftCount2 = _tbGift2.Param[0];
            for (var i = 0; i < DataModel.Option.Count; i++)
            {
                DataModel.Option[i] = new AnswerQuestionDataModel();
            }
            for (var i = 0; i < 6; i++)
            {
                var _tt = i % 2;
                if (_tt == 0)
                {
                    DataModel.RewardItems8[i / 2]        = new ItemIdDataModel();
                    DataModel.RewardItems8[i / 2].ItemId = _tbGift1.Param[i + 1];
                }
                else
                {
                    DataModel.RewardItems8[i / 2].Count = _tbGift1.Param[i + 1];
                }
            }
            for (var i = 0; i < 6; i++)
            {
                var _tt = i % 2;
                if (_tt == 0)
                {
                    DataModel.RewardItems15[i / 2]        = new ItemIdDataModel();
                    DataModel.RewardItems15[i / 2].ItemId = _tbGift2.Param[i + 1];
                }
                else
                {
                    DataModel.RewardItems15[i / 2].Count = _tbGift2.Param[i + 1];
                }
            }
        }
コード例 #2
0
        public async Task <IActionResult> CreateAnswer(QuestionDetailandAnswer model, String id)
        {
            var datamodel = new AnswerDataModel
            {
                QuestionId    = id,
                CreatedUserID = "6e2e6aa0-8392-4892-a177-f1d073355cdd",
                Content       = model.Answer
            };

            string requestStr = "https://www.purgomalum.com/service/containsprofanity?text=" + model.Answer;
            var    request    = new HttpRequestMessage(HttpMethod.Get,
                                                       requestStr);

            var client = _clientFactory.CreateClient();

            var task = client.SendAsync(request);
            var str  = await task.Result.Content.ReadAsStringAsync();

            if (str.Equals("false"))
            {
                string ansRequestStr = "http://localhost:19845/api/answers/";
                var    ansRequest    = new HttpRequestMessage(HttpMethod.Post, ansRequestStr);
                ansRequest.Content = new StringContent(JsonConvert.SerializeObject(datamodel), Encoding.UTF8, "application/json");
                var ansclient = _clientFactory.CreateClient();
                var ansTask   = ansclient.SendAsync(ansRequest);
                var ansStr    = await ansTask.Result.Content.ReadAsStringAsync();

                return(RedirectToAction("QuestionDetail", "QnA", new { id = id }));
                //return Ok(ansStr);
            }
            else
            {
                return(RedirectToAction("QuestionDetailError", "QnA", new { id = id }));
                //return Ok("Check your answer. Improper use of language.");
            }
        }