public ActionResult Index(string category) { JsonpResult jr = new JsonpResult(); jr.JsonRequestBehavior = JsonRequestBehavior.AllowGet; TypeItImage img = new TypeItImage(); //go to wikipedia to get some data! if (category == null) { ViewBag.Message = "Your category is empty"; } else if (category == "Test") { img.Src = "http://paradoxoff.com/files/2012/12/hitachi-seaside-park-2.jpg"; img.Word = "Flowers"; jr.Data = img; return(jr); } else //real data { WikiPediaService srv = new WikiPediaService(); YoutubeService youtubeSrv = new YoutubeService(); //for example this will return for category = "dog" //["dog",["Dog","Doge of Venice","Dogma","Dog breed","Dogfight","Dogwood","Dog sled","Doge's Palace, Venice","Dog Day Afternoon","D\u014dgen"]] try { List <WikiImage> imgs = srv.GetImages(category); if (imgs.Count > 0) { img.Src = imgs[0].Uri; img.Word = imgs[0].Title; //grab the reward video img.RewardVideo = youtubeSrv.GetVideo(category); jr.Data = img; return(jr); } ViewBag.Message = "No images were found! "; } catch (System.Exception ex) { // System.Diagnostics.Debug.WriteLine(ex.Message); ViewBag.Message = "There was an error! " + ex.Message; } } return(View()); }
/// <summary> /// /// </summary> /// <param name="UserName"></param> /// <param name="Word"></param> /// <param name="Duration"></param> /// <param name="Panic"></param> /// <param name="Bored"></param> /// <returns></returns> public ActionResult GetUserData(string UserName) { //get the latest stats and put in the message ViewBag.Message = "Stats: Updated"; UserInfo user = new UserInfo(); UserConfig config = user.GetUserData(UserName); JsonpResult jr = new JsonpResult(); jr.JsonRequestBehavior = JsonRequestBehavior.AllowGet; jr.Data = config; jr.CallbackName = "jsonUserDataCallback"; return(jr); }
public ActionResult GetWords(string UserName) { //get the latest stats and put in the message ViewBag.Message = "Stats: Words Updated"; UserInfo user = new UserInfo(); List <WordStat> words = user.GetWords(UserName); JsonpResult jr = new JsonpResult(); jr.JsonRequestBehavior = JsonRequestBehavior.AllowGet; jr.Data = words; jr.CallbackName = "jsonAvailableWordsCallback"; return(jr); }
/// <summary> /// /// </summary> /// <param name="UserName"></param> /// <param name="Word"></param> /// <param name="Duration"></param> /// <param name="Panic"></param> /// <param name="Bored"></param> /// <returns></returns> public ActionResult GetStats(string UserName, string Word) { //get the latest stats and put in the message ViewBag.Message = "Stats: Delivered"; UserInfo user = new UserInfo(); List <WordStat> stats = user.GetStats(UserName, Word); JsonpResult jr = new JsonpResult(); jr.JsonRequestBehavior = JsonRequestBehavior.AllowGet; jr.Data = stats; jr.CallbackName = "jsonUserHistoryCallback"; return(jr); }