Exemple #1
0
        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());
        }
Exemple #2
0
        /// <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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        /// <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);
        }