public ActionResult Stock(int? id)
        {
            if (id.HasValue)
            {
                StockBO stock = new StockBO(new Herds(HerdBO.GetXmlEntries()), id.Value);
                string t = stock.GetJSONStock(id.Value);
                string jsonFormatted = JValue.Parse(t).ToString(Newtonsoft.Json.Formatting.Indented);
                ViewBag.str = jsonFormatted;
            }
            else
                ViewBag.str = "No day index";

            return View();
        }
        public ActionResult Stock()
        {
            int id;
            if (int.TryParse(Request.QueryString.Get("id"), out id))
            {
                StockBO stock = new StockBO(new Herds(HerdBO.GetXmlEntries()), id);
                var t = stock.GetJSONStock(id);
                string jsonFormatted = JValue.Parse(t).ToString(Newtonsoft.Json.Formatting.Indented);
                ViewBag.str = jsonFormatted;
            }
            else
                ViewBag.str = "No day index";

            return View();
        }
示例#3
0
        static void TestJsonStock()
        {
            int day;
            Console.WriteLine("Enter number of the day for JSON stock!!!");
            string input = Console.ReadLine();
            if (int.TryParse(input, out day))
            {
                StockBO stock = new StockBO(new Herds(HerdBO.GetXmlEntries()), day);

                Console.WriteLine(stock.GetJSONStock(day));
                Main();
            }
            else
            {
                Console.WriteLine("You entered a string!!! Try again");
                Console.WriteLine();
                TestJsonStock();
            }
        }