コード例 #1
0
        public string[] PostChannel([FromBody] List <Object> li)
        {
            int    id      = JsonConvert.DeserializeObject <int>(li[0].ToString());
            string channel = (string)li[1];

            string []     result = new string[2];
            List <string> list   = new List <string>();
            TV            tv2    = new TV();

            id++;
            if (applienceDictionary.ContainsKey(id))

            {
                tv2 = applienceDictionary[id] as TV;
                tv2.AddChannel(channel);
                result[0] = "Your channel added";
                list      = (List <string>)tv2.ShowChannels();
                string channels = @"<ul>";

                foreach (string ch in list)
                {
                    channels += "<li>" + ch + @"</li>";
                }

                channels += "</ul>";
                result[1] = channels;
            }

            return(result);
        }