コード例 #1
0
        //http://localhost:9001/api/BikeRental/Get
        public JsonResult <BikeResponse> Get()
        {
            var returnMe = new BikeResponse();

            returnMe.initialDataSet = new List <List <object> >();
            var object1 = new List <object>();

            object1.Add(1);
            object1.Add("Hello");
            returnMe.initialDataSet.Add(object1);

            var object2 = new List <object>();

            object2.Add(2);
            object2.Add("World");
            returnMe.initialDataSet.Add(object2);

            var object3 = new List <object>();

            object3.Add(3);
            object3.Add("Friday Tomorrow!");
            returnMe.initialDataSet.Add(object3);

            return(Json(returnMe));
        }
コード例 #2
0
        // https://localhost:9001/api/BikeRental/Get2?request=rentals
        public JsonResult <BikeResponse> Get2(string request)
        {
            if (dataset.Count == 0)
            {
                // Load the dummy data first
                LoadData();
            }
            var resp = new BikeResponse();

            resp.initialDataSet = new List <List <object> >();
            switch (request)
            {
            case "registered":
            {
                break;
            }

            case "casual":
            {
                break;
            }

            case "rentals":
            {
                foreach (var d in dataset)
                {
                    var obj = new List <object>();
                    obj.Add(d.date.Ticks);
                    obj.Add(d.count);
                    resp.initialDataSet.Add(obj);
                }
                break;
            }

            default:
            {
                break;
            }
            }
            return(Json(resp));
        }