public ActionResult LookAround(double longitude = 0, double latitude = 0, double distance = 20.0, int categoryID=-1)
        {
            List<Location> listPlace = new List<Location>();
                Location cur = new Location();
                cur.LocationID = -1;
                cur.LocationName = "Current Location";
                cur.Longitude = longitude;
                cur.Latitude = latitude;
                //if (Request.Form["search"] != null)
                //{
                //    cur.Longitude = Double.Parse(Request.Form["latitude"]);
                //    cur.Latitude = Double.Parse(Request.Form["longitude"]);
                //}
                listPlace = LocationHelpers.Instance.GetAllLocation();
                listPlace.RemoveAll(item => (LocationHelpers.Instance.CalculateDistance(cur, item) - distance) > 0);// tat ca cac dia diem o gan
                List<EventPlace> listEventPlace = new List<EventPlace>();
                List<EventPlace> nearlyEventPlace = new List<EventPlace>();
                listEventPlace = LocationHelpers.Instance.GetAllEventPlace();
                foreach (var item in listPlace)
                {
                    var abc = listEventPlace.FindAll(a => a.LocationID == item.LocationID);
                    if (abc != null)
                        foreach (var x in abc)
                        {
                            nearlyEventPlace.Add(x);
                        }
                }
                List<Location> nearlyLocation = new List<Location>();
                List<Event> nearlyEvent = new List<Event>();
                nearlyEventPlace = nearlyEventPlace.Distinct().ToList();
                foreach (var item in nearlyEventPlace)
                {
                    var evt = EventDatabaseHelper.Instance.GetEventByID(item.EventID);
                    if (categoryID == -1)
                    {
                        var place = LocationHelpers.Instance.GetLocationById(item.LocationID);
                        nearlyLocation.Add(place);
                        nearlyEvent.Add(evt);
                    }
                    else if (evt.CategoryID == categoryID) {
                        var place = LocationHelpers.Instance.GetLocationById(item.LocationID);
                        nearlyLocation.Add(place);
                        nearlyEvent.Add(evt);
                    }
                }

                nearlyEvent = nearlyEvent.Distinct().ToList();
                nearlyLocation = LocationHelpers.Instance.RemovePlaceByDistance(nearlyLocation, 1);
                ViewData["currentLocation"] = cur;
                ViewData["nearlyEvent"] = EventDatabaseHelper.Instance.GetThumbEventListByListEvent(nearlyEvent);
                ViewData["nearlyLocation"] = nearlyLocation.Distinct().ToList();
                return PartialView("_LookAround");
        }
        public async Task<ActionResult> CreateEvent(CreateEventModel model)
        {
            if (ModelState.IsValid)
            {
                var LocationName = model.LocationName;
                var lattitude = model.Lattitude;
                var Longitude = model.Longitude;
                var locationList = Regex.Split(LocationName, ";");
                var lattitudeList = Regex.Split(lattitude, ";");
                var longitudeList = Regex.Split(Longitude, ";");
                var locationID = new List<double>();
                for (var i = 0; i < locationList.Length - 1; i++)
                {
                    double tmp = LocationHelpers.Instance.FindLocationByAllData(double.Parse(longitudeList[i]),
                        double.Parse(lattitudeList[i]),
                        locationList[i]);
                    if (
                        tmp == -1)
                    {
                        var newLocation = new Location();
                        newLocation.LocationName = locationList[i];
                        newLocation.Latitude = double.Parse(lattitudeList[i]);
                        newLocation.Longitude = double.Parse(longitudeList[i]);
                        db.Locations.Add(newLocation);
                        db.SaveChanges();
                        tmp = LocationHelpers.Instance.FindLocationByAllData(double.Parse(longitudeList[i]),
                            double.Parse(lattitudeList[i]),
                            locationList[i]);
                    }
                    locationID.Add(tmp);
                }
                var newEvent = new Event();
                newEvent.EventName = model.Title;
                var userChannel =
                    db.Channels.ToList().Find(c => c.UserID.Equals(long.Parse(Session["UserId"].ToString())));
                newEvent.ChannelID = userChannel.ChannelID;
                newEvent.EventStartDate = model.StartTime;
                newEvent.EventEndDate = model.EndTime;
                newEvent.EventDescription = model.Description;
                newEvent.EventRegisterDate = DateTime.Now;
                newEvent.View = 0;
                newEvent.CategoryID = model.CategoryID;
                newEvent.Privacy = model.Privacy;
                newEvent.Avatar = null;
                newEvent.EditBy = long.Parse(Session["UserId"].ToString());
                newEvent.EditTime = DateTime.Now;
                newEvent.EditContent = null;
                newEvent.Status = true;
                // insert Event to Database
                db.Events.Add(newEvent);
                db.SaveChanges();

                //Insert to Event Place
                for (var i = 0; i < locationID.Count; i++)
                {
                    var newEventPlace = new EventPlace();
                    newEventPlace.LocationID = (long) locationID[i];
                    newEventPlace.EventID = newEvent.EventID;
                    db.EventPlaces.Add(newEventPlace);
                    db.SaveChanges();
                }

                /*if (model.IsLive)
                {
                    string[] ViewDataResult =
                        new EventController().Run(model.Title, model.StartTime, model.EndTime, model.Resolution,
                            model.PrivacyYoutube).Result;
                    ViewData["StreamName"] = ViewDataResult[0];
                    ViewData["PrimaryServerURL"] = ViewDataResult[1];
                    ViewData["BackupServerURL"] = ViewDataResult[2];
                    ViewData["YoutubeURL"] = ViewDataResult[3];
                }*/
                return RedirectToAction("Details", "Event", new {id = newEvent.EventID});
                //return RedirectToAction("Index", "Home");
            }

            // If we got this far, something failed, redisplay form
            return RedirectToAction("Create", "Event");
        }