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

            return View();
        }
        public string Order(int? id, Decimal? milk, int? skins)
        {
            int day;
            Decimal milkQ;
            int skinsQ;

            if (!id.HasValue || !milk.HasValue || !skins.HasValue)
            {
                return "Missing data";
            }
            else
            {
                day = id.Value;
                milkQ = milk.Value;
                skinsQ = skins.Value;

                StockBO stock = new StockBO(new Herds(HerdBO.GetXmlEntries()), day, milkQ, skinsQ);

                Response.ContentType = "application/json";
                Response.StatusCode = (int)stock.data[0];
                return (string)stock.data[1];
            }
        }
        public string OrderConsole(int id, OrderInputModel input)
        {
            input.GetRequestFromReST();

            StockBO stock = new StockBO(new Herds(HerdBO.GetXmlEntries()), id, input.Request.order.milk, input.Request.order.skins);

            Response.ContentType = "application/json";
            Response.StatusCode = (int)stock.data[0];
            return (string)stock.data[1];
        }
        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();
        }
Ejemplo n.º 6
0
        static void TestSheep()
        {
            int dayNum;

            Console.WriteLine("Enter number of the day!!!");

            var dayNumString = Console.ReadLine();
            List<Animals> aList = new List<Animals>();
            Herds herd;
            StockBO stock;
            var context = new ABusiness.ABEntities();

            if (int.TryParse(dayNumString, out dayNum))
            {
                herd = new Herds(HerdBO.GetXmlEntries());

                stock = new StockBO(herd, dayNum);

                Console.WriteLine();
                Console.WriteLine("In Stock:");
                Console.WriteLine("   " + string.Format("{0:0.000}", stock.ReturnMilkStock()) + " liters of milk");
                Console.WriteLine("   " + stock.ReturnSkinStock().ToString() + " skins of wool");
                Console.WriteLine("Herd: ");

                foreach( string str in stock.GetHerdAges())
                    Console.WriteLine(str);

                Console.WriteLine();
                Main();
            }
            else
            {
                Console.WriteLine("You entered a string!!! Try again");
                Console.WriteLine();
                TestSheep();
            }
        }
Ejemplo n.º 7
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();
            }
        }