示例#1
0
        public void CompositeJsonResultTest()
        {
            var result1 = new Models.JsonResult();

            for (int i = 0; i < 50; i++)
            {
                JObject jObj = new JObject();
                for (int j = 0; j < 10; j++)
                {
                    string keyName  = string.Format("AttributeKey1-{0}", j);
                    string keyValue = string.Format("AttributeValue1-{0}", j);
                    jObj[keyName] = keyValue;
                }
                result1.rows.Add(jObj);
            }

            var result2 = new Models.JsonResult();

            for (int i = 0; i < 20; i++)
            {
                JObject jObj = new JObject();
                for (int j = 0; j < 7; j++)
                {
                    string keyName  = string.Format("AttributeKey2-{0}", j);
                    string keyValue = string.Format("AttributeValue2-{0}", j);
                    jObj[keyName] = keyValue;
                }
                result2.rows.Add(jObj);
            }

            var result3 = new Models.JsonResult();

            for (int i = 0; i < 10; i++)
            {
                JObject jObj = new JObject();
                for (int j = 0; j < 5; j++)
                {
                    string keyName  = string.Format("AttributeKey3-{0}", j);
                    string keyValue = string.Format("AttributeValue3-{0}", j);
                    jObj[keyName] = keyValue;
                }
                result3.rows.Add(jObj);
            }

            var composite = new CompositeJsonResult {
                Result1 = result1, Result2 = result2, Result3 = result3
            };
            string output = JsonConvert.SerializeObject(composite);

            Assert.IsFalse(String.IsNullOrEmpty(output));
        }
示例#2
0
 public ActionResult <Models.JsonResult> sendMessage(string pesan)
 {
     try
     {
         telegramBot.BOT_SendMessageAsync(pesan);
         Models.JsonResult jsonResult = new Models.JsonResult {
             JSONMessage = "Pesan kekirim", JSONResult = true, JSONRows = 0, JSONValue = null
         };
         return(jsonResult);
     }
     catch (Exception ex)
     {
         Repository.RepSqlDatabase.LogErrorQuery(_hostEnvironment, "Telegram.sendMessage", ex);
         return(BadRequest("Error while creating"));
     }
 }