Exemplo n.º 1
0
        // GET: Places/Delete/5
        public ActionResult Delete()
        {
            using (StreamReader reader = new StreamReader(Server.MapPath("~/Content/sportsTwitterSearch.json")))
            {
                string result = reader.ReadToEnd();
                var    json   = JObject.Parse(result);
                var    trend  = json["statuses"];

                var stwitters = new List <Stwitter>();

                dynamic dynJson = JsonConvert.DeserializeObject(trend.ToString());

                foreach (var item in dynJson)
                {
                    Stwitter stwitter = new Stwitter();
                    stwitter.Screen_name       = item["user"]["screen_name"];
                    stwitter.Created_at        = item["created_at"];
                    stwitter.Url               = item["user"]["url"];
                    stwitter.Text              = item["text"];
                    stwitter.User_description  = item["user"]["description"];
                    stwitter.Followers_count   = item["user"]["followers_count"];
                    stwitter.Friends_count     = item["user"]["friends_count"];
                    stwitter.Profile_image_url = item["user"]["profile_image_url"];

                    if (item["user"]["url"] == "None")
                    {
                        stwitter.Url = "https://twitter.com";
                    }

                    stwitters.Add(stwitter);
                }
                //var trends = JsonConvert.DeserializeObject<List<Trend>>(trend).Take(12);

                ViewData["sportsTwitter"] = stwitters.Take(3);
            }

            return(View());
        }
Exemplo n.º 2
0
        // GET: Places/Details/5
        //Get food type data
        public ActionResult Details(string searchString, string searchString1)
        {
            GetFoodData(searchString, searchString1);

            Place place = new Place();

            var places = db.Place.Include(p => p.Field).Where(s => s.Field_id == 4).OrderByDescending(a => a.Rating);

            var ps = from s in places
                     select s;

            if (!(String.IsNullOrEmpty(searchString) && String.IsNullOrEmpty(searchString1)))
            {
                ps = ps.Where(s => s.Adress.Contains(searchString) && s.Photo_reference.Contains(searchString1));
            }

            Place pl = ps.FirstOrDefault();

            if (pl == null)
            {
                ViewData["Message"] = "Sorry, there is no clubs in your suburb!You can select Melbourne to see all";
            }
            else
            {
                ViewData["Message"] = null;
            }
            ViewData["Places"] = ps;

            using (StreamReader reader = new StreamReader(Server.MapPath("~/Content/foodTwitterSearch.json")))
            {
                string result = reader.ReadToEnd();
                //var json = JObject.Parse(result);
                var json  = JObject.Parse(result);
                var trend = json["statuses"];

                var stwitters = new List <Stwitter>();

                dynamic dynJson = JsonConvert.DeserializeObject(trend.ToString());

                foreach (var item in dynJson)
                {
                    Stwitter stwitter = new Stwitter();
                    stwitter.Screen_name       = item["user"]["screen_name"];
                    stwitter.Created_at        = item["created_at"];
                    stwitter.Url               = item["user"]["url"];
                    stwitter.Text              = item["text"];
                    stwitter.User_description  = item["user"]["description"];
                    stwitter.Followers_count   = item["user"]["followers_count"];
                    stwitter.Friends_count     = item["user"]["friends_count"];
                    stwitter.Profile_image_url = item["user"]["profile_image_url"];

                    if (item["user"]["url"] == "None")
                    {
                        stwitter.Url = "https://twitter.com";
                    }

                    stwitters.Add(stwitter);
                }
                //var trends = JsonConvert.DeserializeObject<List<Trend>>(trend).Take(12);

                ViewData["sportsTwitter"] = stwitters;
            }

            return(View());
        }