public ActionResult Create(string address, string placeName) { if (address == string.Empty) { ModelState.AddModelError("address", "Please add a Address"); return(View()); } if (placeName == string.Empty) { ModelState.AddModelError("placeName", "Please add a Name"); return(View()); } else { GeoCoordinate LadLonAddress = GetLatitudeLongitudeFromAddress.FindLocation(address); db.NoGoZones.Add(new NoGoZone { PlaceName = placeName, UserId = User.Identity.GetUserId(), Latitude = LadLonAddress.Latitude, Longitude = LadLonAddress.Longitude, Address = address, }); db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Edit(string address, string placeName, int id) { if (address == string.Empty) { ModelState.AddModelError("address", "Please add a Address"); return(View()); } if (placeName == string.Empty) { ModelState.AddModelError("placeName", "Please add a Name"); return(View()); } else { GeoCoordinate LadLonAddress = GetLatitudeLongitudeFromAddress.FindLocation(address); var EditNoGo = db.NoGoZones.Find(id); if (EditNoGo.UserId != User.Identity.GetUserId()) { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized)); } EditNoGo.Latitude = LadLonAddress.Latitude; EditNoGo.Longitude = LadLonAddress.Longitude; EditNoGo.PlaceName = placeName; EditNoGo.Address = address; db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult GetLadLon(string address) { GeoCoordinate LadLonAddress = GetLatitudeLongitudeFromAddress.FindLocation(address); LocationMap Location = new LocationMap { Latitude = LadLonAddress.Latitude, Longitude = LadLonAddress.Longitude, Description = "Hallo", Title = "Blabla" }; return(Json(Location, JsonRequestBehavior.AllowGet)); }