Beispiel #1
0
        //public JsonResult detailasjson(string crit) {
        //// ----------------------------------------------
        //   List<CMlbPlayer> py = dbinfo.SearchPlayers(crit);
        //   var s = Json(py, JsonRequestBehavior.AllowGet);
        //   return Json(py, JsonRequestBehavior.AllowGet);

        //}


        public JsonResult GetTeamsForYear(int yr)
        {
            // --------------------------------------------------------------------------------------
            //var ret = new[] {
            //   new { teamTag = "NYY", teamName = "NYY Yankees" },
            //   new { teamTag = "BOS", teamName = "BOS Red Sox" }
            //};
            //var ret = new List<object>();
            //ret.Add(new { teamTag = "NYY", teamName = "NYY Yankees" });
            //ret.Add(new { teamTag = "BOS", teamName = "BOS Red Sox" });
            //ret.Add(new { teamTag = "PHI", teamName = "PHI Phillies" });

            try {
                var ret = info.GetTeamsForYear(yr);

                string s = Json(ret, JsonRequestBehavior.AllowGet).ToString();
                return(Json(ret, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex) {
                string msg =
                    $"An error occurred retrieving available teams for {yr}:\r\n" +
                    ex.Message;
                return(Json(msg, JsonRequestBehavior.AllowGet));
            }
        }