public async Task<ActionResult> CreateEvent(CreateEventModel model, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                List<Location> locationList = model.Location;
                locationList.RemoveAll(o => o.LocationName.Equals("Remove Location"));
                //add location to database
                var listLocation = LocationHelpers.Instance.AddNewLocation(locationList);

                //Adding new event with given infomation to database
                var newEvent = EventDatabaseHelper.Instance.AddNewEvent(model, file, UserHelpers.GetCurrentUser(Session).UserID);

                //Add event place to database
                var listEventPlaces = EventDatabaseHelper.Instance.AddEventPlace(listLocation, newEvent);

                LiveStreamingModel liveModel = new LiveStreamingModel { eventID = newEvent.EventID, Title = newEvent.EventName };
                TempData["LiveModel"] = liveModel;
                HttpCookie newEventID = new HttpCookie("CreateEventID");
                newEventID.Value = newEvent.EventID.ToString();
                newEventID.Expires=DateTime.Now.AddDays(1);
                Response.Cookies.Add(newEventID);
                NotificationDataHelpers.Instance.SendNotifyNewEventToFollower(UserHelpers.GetCurrentUser(Session).UserID, newEvent.EventID);
                return RedirectToAction("Details", "Event",new{id=newEvent.EventID});
            }
            // If we got this far, something failed, redisplay form
            ViewBag.CategoryID = new SelectList(db.Categories, "CategoryId", "CategoryName");
            TempData["errorTitle"] = "Error";
            TempData["errorMessage"] = "Please select location from suggestion!"; 
            return View("Create", model);
        }
        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");
        }